Select to view content in your preferred language

Need Scripted Method to Register a Feature Class as Versioned

891
7
05-04-2011 10:38 AM
JasonLongenecker
New Contributor
Need Scripted Method to Register a Feature Class as Versioned

I�??m searching for a scripted method to register a feature class as versioned.

1) One is able to register a feature class with the geodatabase via sdelayer -o register
2) One is able to grant permissions via sdelayer �??o grant
3) One is able to register a feature class as versioned by using ArcCatalog
           a. Via the GUI or via the geoprocessing tools
4) One is able to use sdetable �??o register a table with geodatabase and register it as versioned

How do you perform register as versioned for a feature class using SDE command line, SQL or any other scripted method?

Note: I hope their is a simple answer I've over looked.

Regards,
Jason Longenecker
0 Kudos
7 Replies
JakeSkinner
Esri Esteemed Contributor
You can register a feature class via command line using the 'sdetable -o alter_reg' command with the '-V MULTI' option.  Ex:
sdetable -o alter_reg -t building -V MULTI -i sde:sqlserver:esri -D vector -u vector -p ****


You could also register a feature class as versioned using python.  Ex:

import arcpy
from arcpy import env

env.workspace = r"Database Connections\SQL.sde"

fc = "Parcels"

arcpy.RegisterAsVersioned_management(fc)
0 Kudos
JasonLongenecker
New Contributor
I've tried a version of this command but will try using your recommendations later this week and post my results. 

Thank you!
0 Kudos
JasonLongenecker1
Emerging Contributor
I ran the command and got the following error:

C:\>sdetable -o alter_reg -t TBL_TEST -V MULTI -u ARC1 -p ARC -D DCNSDB


ArcSDE 10.0  for Oracle11g Build 775 Fri Sep 17 11:45:27  2010
Attribute        Administration Utility
-----------------------------------------------------
Alter registration for table TBL_TEST. Are you sure? (Y/N): Y
        Error: The current table doesn't have an SDE-maintained row_id column (-169).
        Error: Unable to alter registration for table TBL_TEST


For reference here is the command I used to register this table with the geodatabase.

sdelayer -o register -l TBL_TEST,SHAPE -C NODE_ID,USER -t SDO_GEOMETRY -e p -E -200000,-125000,570000,250000 -P BASIC -u ARC1 -p ARC -D DCNSDB


What are the steps to get a third party Oracle spatial table to be registered as versioned?

Also note I want edits to occur on the base table.
0 Kudos
VinceAngelo
Esri Esteemed Contributor
You've got a bunch of issues here:

ArcGIS 10 requires HIGH precision on SDO_GEOMETRY and ST_GEOMETRY layers --
No workaround.

Versioning requires an SDE-set rowid column -- No workaround.

"Move edits to base" versioning requires ArcGIS (both to establish it, and to edit it) --
No workaround.

I'm afraid you're going to have to alter your plan.  You might be able to use Oracle
STREAMS to propagate changes made in a parallel ArcGIS-registered table, but you'd
be hard-pressed to get propagation to be two-way. 😞

- V
0 Kudos
JasonLongenecker1
Emerging Contributor
I appreciate the direct feedback.  Let's say for a minute that I abandon versioned edits all together.

What are your thoughts on this alternative using non-versioned editing?

1) CREATE TABLE TBL_TEST... in Oracle.

CREATE TABLE TBL_TEST
(
NID    NUMBER(10,0) NOT NULL,
NAME   NVARCHAR2(50),
SE_ANNO_CAD_DATA BLOB,
SHAPE   MDSYS.SDO_GEOMETRY NOT NULL,
CONSTRAINT PK_TEST_NID PRIMARY KEY (NID)
);

2) INSERT a few records leaving only the SE_ANNO_CAD_DATA column empty.

3) INSERT Metadata in SDO GEOM table.

INSERT INTO USER_SDO_GEOM_METADATA VALUES
('TBL_TEST','SHAPE',MDSYS.SDO_DIM_ARRAY(MDSYS.SDO_DIM_ELEMENT('X_COORD',-200000,570000,0.0003),MDSYS.SDO_DIM_ELEMENT('Y_COORD',-125000,250000,0.0003)),2804);

4) CREATE a spatial index.

CREATE INDEX IDX_TEST ON TBL_TEST(SHAPE) INDEXTYPE IS MDSYS.SPATIAL_INDEX;

5) Execute SDELAYER -o REGISTER

sdelayer -o register -l TBL_TEST,SHAPE -C NID,USER -t SDO_GEOMETRY -e p -E -200000,-125000,570000,250000 -P BASIC -u ARC1 -p ARC -D DCNSDB

6) Open up ArcMap, set edit options to non-versioned and set attributes to be entered before edit is commited.

7) Place point on map, enter attributes and save edits.

Would something like this work given the objectid is user managed?

I need SDE to view and perform simple edits on 3rd party Ora Spatial DB tables.  I've been succesful in registering Oracle tables for viewing by ArcSDE.  But no success on being able to edit these 3rd party tables.

My issue is further compounded because the Oracle data model I'm working with has several tables with multiple shape columns.  Do non-versioned edits work on simple Oracle views that have a single shape column?  No documentation I've encountered has specifically addressed this.
0 Kudos
JasonLongenecker1
Emerging Contributor
Additional Notes:

When I perform the steps I describe above I am able to move points, modify attributes and save edits so they are commited to the Oracle database while using non-versioned editing.

I am not able to add new records.  I've forced attributes to be entered before new shapes created are commited.

I've put code below to show steps.

--Create Tables--

CREATE TABLE TBL_TESTING
(
NODE_ID    NUMBER(10,0) NOT NULL,
NODE_NAME   VARCHAR2(50),
SE_ANNO_CAD_DATA BLOB,
SHAPE   MDSYS.SDO_GEOMETRY NOT NULL,
CONSTRAINT PK_TEST_NODE_ID PRIMARY KEY (NODE_ID)
);

--Insert Records--

INSERT INTO TBL_TESTING (NODE_ID,NODE_NAME,SE_ANNO_CAD_DATA,SHAPE)
SELECT NODE_ID, NODE_NAME, SE_ANNO_CAD_DATA, SHAPE
FROM FRE2.TST_TELCO_NODES T
WHERE T.NODE_ID < 10;

--Create Views--

CREATE OR REPLACE VIEW PTS_TEST AS
SELECT NODE_ID, NODE_NAME, SE_ANNO_CAD_DATA, SHAPE
FROM TBL_TESTING;

--Update SHAPE Column SRID's--

UPDATE TBL_TESTING T
SET T.SHAPE.SDO_SRID = 2804;

--Insert SDO Geometry Metadata--

INSERT INTO USER_SDO_GEOM_METADATA VALUES
('TBL_TESTING','SHAPE',MDSYS.SDO_DIM_ARRAY(MDSYS.SDO_DIM_ELEMENT('X_COORD',-200000,570000,0.0003),MDSYS.SDO_DIM_ELEMENT('Y_COORD',-125000,250000,0.0003)),2804);

INSERT INTO USER_SDO_GEOM_METADATA VALUES
('PTS_TEST','SHAPE',MDSYS.SDO_DIM_ARRAY(MDSYS.SDO_DIM_ELEMENT('X_COORD',-200000,570000,0.0003),MDSYS.SDO_DIM_ELEMENT('Y_COORD',-125000,250000,0.0003)),2804);

--Create Spatial Indices--

CREATE INDEX IDX_TEST ON TBL_TESTING(SHAPE) INDEXTYPE IS MDSYS.SPATIAL_INDEX;

--Create Sequence--

CREATE SEQUENCE SEQ_TEST
MINVALUE 1
MAXVALUE 1000000000
START WITH 1000
INCREMENT BY 1;

--Create Sequence Trigger--

CREATE OR REPLACE TRIGGER TRG_SEQ_PK_TBL_TEST BEFORE
INSERT ON TBL_TESTING FOR EACH ROW BEGIN
   SELECT seq_test.NEXTVAL INTO :new.NODE_ID  FROM DUAL;
END;
/

--sdelayer -o delete -l TBL_TESTING,SHAPE -u ARC1 -p ARC -D DCNSDB -N--
--sdelayer -o delete -l PTS_TEST,SHAPE -u ARC1 -p ARC -D DCNSDB -N--

--sdelayer -o register -l TBL_TESTING,SHAPE -C NODE_ID,USER -t SDO_GEOMETRY -e p -E -200000,-125000,570000,250000 -P BASIC -u ARC1 -p ARC -D DCNSDB--
--sdelayer -o register -l PTS_TEST,SHAPE -C NODE_ID,USER -t SDO_GEOMETRY -e p -E -200000,-125000,570000,250000 -P BASIC -u ARC1 -p ARC -D DCNSDB--
0 Kudos
JasonLongenecker1
Emerging Contributor
Any thoughts?
0 Kudos