1

我已经将我的表的几何图形转换为一个只有两个字段(Geometry 和 SDO_RowID)的新表

我需要获取原始表中的所有数据并将其带到新表中。我在新表中创建了列,现在我正在尝试使用 For Update Of 游标来获取数据。

我只是不确定如何以正确的方式遍历所有数据/使其工作。谢谢。

DECLARE
    CURSOR OTTAWACOLLECTS IS 
    SELECT SHAPE_LENG,
           CLASS,
           SUBCLASSIF,
           ROAD_NAME,
           ROAD_TYPE,
           ROAD_DIREC,
           MUNICIPALI,ADDRESS_LE,
           ADDRESS__1, 
           ADDESSS_RI,
           ADDRESS_RI, ROAD_NAME_
    FROM OTTAWACOLLECTORS
    WHERE OTTAWACOLLECTORS_NAD.SDO_ROWID = ROWID
    FOR UPDATE OF OTTAWACOLLECTORS_NAD;

BEGIN
    FOR ROWID IN OTTAWACOLLECTS
    LOOP
        UPDATE OTTAWACOLLECTORS_NAD
        SET SHAPE_LENG = OTTAWACOLLECTORS.SHAPE_LENG,
            CLASS = OTTAWACOLLECTORS.CLASS,
            SUBCLASSIF = OTTAWACOLLECTORS.SUBCLASSIF,
            ROAD_NAME = OTTAWACOLLECTORS.ROAD_NAME,
            ROAD_TYPE = OTTAWACOLLECTORS.ROAD_TYPE,
            ROAD_DIREC = OTTAWACOLLECTORS.ROAD_DIREC,
            MUNICIPALI = OTTAWACOLLECTORS.MUNICIPALI,
            ADDRESS_LE = OTTAWACOLLECTORS.ADDRESS_LE,
            ADDRESS__1 = OTTAWACOLLECTORS.ADDRESS__1,
            ADDRESSS_RI = OTTAWACOLLECTORS.ADDESSS_RI,
            ADDRESS_RI = OTTAWACOLLECTORS.ADDRESS_RI,
            ROAD_NAME = OTTAWACOLLECTORS.ROAD_NAME_
        WHERE CURRENT OF OTTAWACOLLECTS;
    END LOOP;
END;
4

1 回答 1

0

看起来您使用该sdo_cs.transform_layer()函数获得了新表。IMO 你只是用这种方法让你的生活变得不必要地复杂。有两种更简单的方法:

1)只需转换原始表中的几何图形。或者,如果您需要两个坐标系(原始坐标系和新坐标系)中的几何图形,则只需在原始表中添加第二个几何图形列。您甚至可以通过触发器链接它们,这样当“主”几何图形更新时,转换后的几何图形就会自动更新。

alter table ottawacollectors add geometry_nad do_geometry;
update ottawacollectors set geometry_nad = sdo_cs.transform (geometry, <your new SRID>);
commit;

然后在附加列上添加元数据和空间索引。

好处是您不需要处理两个单独的表,它们都具有您需要保持同步的相同内容。

2) 或者,如果您真的想要原始表的完整副本以及转换后的几何形状,那么只需创建该新表并同时进行转换,如下所示:

create table ottawacollectors_nad as
select ... (all columns) ..., sdo_cs.transform (geometry, <your new SRID>) geometry
from ottawacollectors;

或者更简单:

create table ottawacollectors_nad as select * from ottawacollectors;

其次是:

update ottawacollectors_nad set geometry = sdo_cs.transform (geometry, <your new SRID>);
commit;

之后是通常的元数据设置和空间索引的创建。

于 2015-06-12T07:37:39.697 回答