HOW TO
In manchen Fällen kann es notwendig sein, einer Feature-Class unter Verwendung der strukturierten Abfragesprache SQL Geometrien hinzuzufügen. Dies ist mithilfe einer Schleife oder eines Datenbank-Cursors in SQL möglich. In bestimmten Fällen empfiehlt es sich wegen der Leistung, Ressourcen oder Workflows eher, Daten über SQL zu erstellen als in ArcMap.
-- Get the number of rows in the looping table DECLARE @RowCount INT SET @RowCount = (SELECT COUNT(*) FROM sde.INPUT_TABLE) -- Declare an iterator DECLARE @iterator INT -- Initialize the iterator SELECT @iterator = MIN(OBJECTID) FROM SDE.INPUT_TABLE -- Loop through the rows of a table @myTable WHILE @iterator is NOT NULL BEGIN DECLARE @id as integer EXEC sde.next_rowid 'sde', 'points', @id OUTPUT; INSERT INTO sde.POINTS (OBJECTID, Shape) SELECT @id, geometry::STPointFromText('POINT('+str(POINT_X, 38, 8) + ' ' + str(POINT_Y, 38, 8) + ')', 2286) as SHAPE FROM sde.INPUT_TABLE where objectid = @iterator; SELECT @iterator= MIN(OBJECTID) FROM SDE.INPUT_TABLE WHERE @iterator < @RowCount END
Im folgenden Beispiel, werden einer Feature-Class Punktgeometrien aus einer vorhandenen Datenbanktabelle hinzugefügt.
Hinweis: Dieses Verfahren funktioniert am besten, wenn die Eingabedatenbanktabelle eine Spalte für eine eindeutige ID wie beispielsweise das Feld "rownum" oder "OID" in SQL Server enthält. Hierdurch wird sichergestellt, dass mit der WHILE-Schleife keine Zeile ausgelassen wird, die nicht eindeutig ist.
Hinweis: Um einer registrierten Feature-Class Daten hinzuzufügen, muss für die ObjectID-Spalte ein eindeutiger Wert angegeben werden, bei dem es sich nicht um einen NULL-Wert handelt. Hierzu muss die Prozedur Next_RowID verwendet werden.SQL Server-Geometrie-Beispiel:
-- Get the number of rows in the looping table DECLARE @RowCount INT SET @RowCount = (SELECT COUNT(*)FROM sde.INPUT_TABLE) -- Declare an iterator DECLARE @iterator INT -- Initialize the iterator SELECT @iterator = MIN(OBJECTID) FROM SDE.INPUT_TABLE -- Loop through the rows of a table WHILE @iterator is NOT NULL BEGIN DECLARE @id as integer EXEC sde.next_rowid 'sde', 'points', @id OUTPUT; INSERT INTO sde.POINTS (OBJECTID, Shape) SELECT @id, geometry::STPointFromText( 'POINT('+str(POINT_X, 38, 8) + ' ' + str(POINT_Y, 38, 8) + ')', 2286) as SHAPE FROM sde.INPUT_TABLE where objectid = @iterator; SELECT @iterator= MIN(OBJECTID) FROM SDE.INPUT_TABLE WHERE @iterator < @RowCount ENDOracle SDO Geometry-Beispiel:
SET SERVEROUTPUT ON -- Declare a cursor DECLARE CURSOR points is select * from sde.input_table; --Loop through the cursor BEGIN FOR pt IN points LOOP INSERT INTO SDE.POINTS (OBJECTID, SHAPE) VALUES ( sde.gdb_util.next_rowid('sde', 'points'), MDSYS.SDO_GEOMETRY(2001,2286,MDSYS.SDO_POINT_TYPE(pt.point_x, pt.point_y,NULL),NULL,NULL) ); END LOOP; COMMIT; END; /Oracle ST Geometry-Beispiel:
SET SERVEROUTPUT ON -- Declare a cursor DECLARE CURSOR points is select * from sde.input_table; --Loop through the cursor BEGIN FOR pt IN points LOOP INSERT INTO SDE.POINTS (OBJECTID, SHAPE) VALUES ( sde.gdb_util.next_rowid('sde', 'points'), sde.ST_Point(pt.point_x,pt.point_y, 2286) ); END LOOP; COMMIT; END; /
Hilfe von ArcGIS-Expert*innen erhalten
Die Esri Support-App herunterladen