如何将一个巨大的几何体插入到 SDO_GEOMETRY 类型的字段中?
how to insert a giant geometry into a field of type SDO_GEOMETRY?
我正在尝试将此 http://pastebin.com/cKXnCqx7 几何图形插入 SDO_GEOMETRY 字段,如下所示:
declare
str clob = http://pastebin.com/cKXnCqx7
begin
INSERT INTO TEMP_TEST_GEOMETRY VALUES (SDO_CS.TRANSFORM (SDO_GEOMETRY (str, 4674), 1000205));
end;
并且正在生成以下错误:
PL/SQL 中字符串文字的最大大小为 32K。您正在尝试分配一个 98K+ 文字,这是导致错误的原因(尽管因为它指的是 4k,这似乎来自普通的 SQL 调用而不是 PL/SQL 您显示的块) .它还没有尝试从 CLOB 创建 sdo_geometry
对象。
理想情况下,您将从一个文件或一些其他为您提供完整 CLOB 的机制中加载值。如果您必须将其视为文字,则必须手动将其分成块;如果你把它们变大,至少有 4 个具有这个值:
declare
str clob;
begin
dbms_lob.createtemporary(str, false);
dbms_lob.append(str, 'POLYGON ((-47.674240062208945 -2.8066454423517624, -47.674313162 -2.8066509996, <...snip...>');
dbms_lob.append(str, '47.6753521374 -2.8067875453, -47.6752566506 -2.8067787567, -47.6752552377 -2.8067785117, <...snip...>');
dbms_lob.append(str, '-47.658134547 -2.8044846153, -47.6581360233 -2.8044849964, -47.6581811229 -2.8044926289, <...snip...>');
dbms_lob.append(str, '-47.6717079633 -2.8057792966, -47.6717079859 -2.80577931, -47.6717083252 -2.8057795101, -47.6718125136 -2.8058408619, -47.6719547186 -2.8059291721, -47.6719573483 -2.8059307844, -47.6719575243 -2.8059308908, -47.6719601722 -2.8059324729, -47.6720975574 -2.8060134925, -47.6721015308 -2.8060157903, -47.6721017969 -2.8060159412, -47.6721058088 -2.806018171, -47.6721847946 -2.8060611947, -47.6721897923 -2.8060650985, -47.6722059263 -2.8060767675, -47.6722070291 -2.8060775047, -47.6722416572 -2.8060971165, -47.6722428566 -2.8060976832, -47.6722611616 -2.8061055189, -47.6722666301 -2.8061076243, -47.6722849174 -2.806116847, -47.6722862515 -2.8061174528, -47.6723066339 -2.8061257231, -47.6723316499 -2.8061347029, -47.6723426416 -2.8061383836, -47.6723433793 -2.8061386131, -47.672354519 -2.8061418177, -47.6723803034 -2.8061486384, -47.6725084039 -2.8061908942, -47.6725130545 -2.8061923817, -47.6725133654 -2.806192478, -47.6725180423 -2.806193881, -47.6728423039 -2.8062879629, -47.6728698649 -2.8062995965, -47.6728952856 -2.8063088527, -47.672897007 -2.8063093833, -47.672949984 -2.8063200428, -47.6729517767 -2.8063202193, -47.672966443 -2.8063209226, -47.6729679855 -2.8063213223, -47.6733393514 -2.8064196858, -47.6733738728 -2.8064264543, -47.6733761939 -2.8064267537, -47.6733804796 -2.8064270239, -47.6733890639 -2.806431641, -47.6734057692 -2.8064398944, -47.6734069006 -2.8064404055, -47.6734241363 -2.8064474849, -47.6736663052 -2.8065373005, -47.6736676833 -2.8065378073, -47.6736677752 -2.8065378409, -47.673669156 -2.8065383402, -47.6737754465 -2.8065764489, -47.673793217 -2.8065850801, -47.6737945765 -2.8065856723, -47.6738366895 -2.8066000123, -47.6738381279 -2.8066003728, -47.6738811819 -2.8066074503, -47.6739137725 -2.8066153813, -47.6739159177 -2.806615636, -47.6739318345 -2.8066165588, -47.673951326 -2.806622013, -47.6739530661 -2.8066223195, -47.6739793945 -2.8066256302, -47.6740948445 -2.8066344025, -47.674240062208945 -2.8066454423517624))');
INSERT INTO TEMP_TEST_GEOMETRY
VALUES (SDO_CS.TRANSFORM (SDO_GEOMETRY (str, 4674), 1000205));
dbms_lob.freetemporary(str);
end;
/
您可以使块更小并添加更多的附加项,这在某些方面可能更易于管理,但设置工作量更大。虽然手动操作仍然很痛苦,所以如果您无法通过其他方式获取值,这可能是最后的手段。
如果字符串来自 HTTP 调用,您可以使用 dbms_lob.append
以大体相同的方式读取块中的响应并将其转换为 CLOB。具体如何取决于您当前用于获取响应的机制。另外值得注意的是 Oracle 12c 有 built-in JSON handling; in earlier versions you may be able to use the third-party PL/JSON module, which seems to handle CLOBs.
我正在尝试将此 http://pastebin.com/cKXnCqx7 几何图形插入 SDO_GEOMETRY 字段,如下所示:
declare
str clob = http://pastebin.com/cKXnCqx7
begin
INSERT INTO TEMP_TEST_GEOMETRY VALUES (SDO_CS.TRANSFORM (SDO_GEOMETRY (str, 4674), 1000205));
end;
并且正在生成以下错误:
PL/SQL 中字符串文字的最大大小为 32K。您正在尝试分配一个 98K+ 文字,这是导致错误的原因(尽管因为它指的是 4k,这似乎来自普通的 SQL 调用而不是 PL/SQL 您显示的块) .它还没有尝试从 CLOB 创建 sdo_geometry
对象。
理想情况下,您将从一个文件或一些其他为您提供完整 CLOB 的机制中加载值。如果您必须将其视为文字,则必须手动将其分成块;如果你把它们变大,至少有 4 个具有这个值:
declare
str clob;
begin
dbms_lob.createtemporary(str, false);
dbms_lob.append(str, 'POLYGON ((-47.674240062208945 -2.8066454423517624, -47.674313162 -2.8066509996, <...snip...>');
dbms_lob.append(str, '47.6753521374 -2.8067875453, -47.6752566506 -2.8067787567, -47.6752552377 -2.8067785117, <...snip...>');
dbms_lob.append(str, '-47.658134547 -2.8044846153, -47.6581360233 -2.8044849964, -47.6581811229 -2.8044926289, <...snip...>');
dbms_lob.append(str, '-47.6717079633 -2.8057792966, -47.6717079859 -2.80577931, -47.6717083252 -2.8057795101, -47.6718125136 -2.8058408619, -47.6719547186 -2.8059291721, -47.6719573483 -2.8059307844, -47.6719575243 -2.8059308908, -47.6719601722 -2.8059324729, -47.6720975574 -2.8060134925, -47.6721015308 -2.8060157903, -47.6721017969 -2.8060159412, -47.6721058088 -2.806018171, -47.6721847946 -2.8060611947, -47.6721897923 -2.8060650985, -47.6722059263 -2.8060767675, -47.6722070291 -2.8060775047, -47.6722416572 -2.8060971165, -47.6722428566 -2.8060976832, -47.6722611616 -2.8061055189, -47.6722666301 -2.8061076243, -47.6722849174 -2.806116847, -47.6722862515 -2.8061174528, -47.6723066339 -2.8061257231, -47.6723316499 -2.8061347029, -47.6723426416 -2.8061383836, -47.6723433793 -2.8061386131, -47.672354519 -2.8061418177, -47.6723803034 -2.8061486384, -47.6725084039 -2.8061908942, -47.6725130545 -2.8061923817, -47.6725133654 -2.806192478, -47.6725180423 -2.806193881, -47.6728423039 -2.8062879629, -47.6728698649 -2.8062995965, -47.6728952856 -2.8063088527, -47.672897007 -2.8063093833, -47.672949984 -2.8063200428, -47.6729517767 -2.8063202193, -47.672966443 -2.8063209226, -47.6729679855 -2.8063213223, -47.6733393514 -2.8064196858, -47.6733738728 -2.8064264543, -47.6733761939 -2.8064267537, -47.6733804796 -2.8064270239, -47.6733890639 -2.806431641, -47.6734057692 -2.8064398944, -47.6734069006 -2.8064404055, -47.6734241363 -2.8064474849, -47.6736663052 -2.8065373005, -47.6736676833 -2.8065378073, -47.6736677752 -2.8065378409, -47.673669156 -2.8065383402, -47.6737754465 -2.8065764489, -47.673793217 -2.8065850801, -47.6737945765 -2.8065856723, -47.6738366895 -2.8066000123, -47.6738381279 -2.8066003728, -47.6738811819 -2.8066074503, -47.6739137725 -2.8066153813, -47.6739159177 -2.806615636, -47.6739318345 -2.8066165588, -47.673951326 -2.806622013, -47.6739530661 -2.8066223195, -47.6739793945 -2.8066256302, -47.6740948445 -2.8066344025, -47.674240062208945 -2.8066454423517624))');
INSERT INTO TEMP_TEST_GEOMETRY
VALUES (SDO_CS.TRANSFORM (SDO_GEOMETRY (str, 4674), 1000205));
dbms_lob.freetemporary(str);
end;
/
您可以使块更小并添加更多的附加项,这在某些方面可能更易于管理,但设置工作量更大。虽然手动操作仍然很痛苦,所以如果您无法通过其他方式获取值,这可能是最后的手段。
如果字符串来自 HTTP 调用,您可以使用 dbms_lob.append
以大体相同的方式读取块中的响应并将其转换为 CLOB。具体如何取决于您当前用于获取响应的机制。另外值得注意的是 Oracle 12c 有 built-in JSON handling; in earlier versions you may be able to use the third-party PL/JSON module, which seems to handle CLOBs.