Select to view content in your preferred language

GlobalID

3096
6
12-10-2010 12:24 PM
AlexProtyagov
Emerging Contributor
Could someone tell me how to register a column as GlobalID using a script.

First I create table in database with sql script.

Next I register it as
sdelayer -o register -l M_SIGN_INVENTORY,GEOM -u %USERID% -p %USERPASSWORD% -e 3npM -x 0,0,3048 -z 0,10000 -P HIGH -t SDO_GEOMETRY -G file=%CRSFILE%


My table has column [GLOBALID], how do I tell esri to use that column as GlobalID.

If I use ArcCatalog and right click on my FeatureClass and select Add GlobalID it creates new column, [GLOBALID1].
0 Kudos
6 Replies
VinceAngelo
Esri Esteemed Contributor
What version of Oracle are you using? Which patchset? Have you applied the
most recent CPU?

What version of ArcSDE are you using? What service pack/patches?

What does your table creation SQL look like?

What does 'sdetable -o describe' report for the table?

You can't register a column as a UUID type. It either is a UUID or it's something else.
ArcSDE uses a NOT NULL VARCHAR2(38) on Oracle, with the leading and training braces,
and the hyphens in the right places.  A registered rowid column is also required (as it is
to register an SDO_GEOMETRY -- you should have a '-C' parameter in the 'sdelayer'
command line).

The programmatic way to define a UUID column in Oracle with ArcSDE is to create
the table with 'sdetable' or some other 'C' or Java API application.  I can't think of any
supported means to convince the table registration code that an existing column is
SE_UUID_TYPE.

- V
0 Kudos
AlexProtyagov
Emerging Contributor
ORACLE VESION : 11g
ArcSDE: 10, I believe they have a service pack, I did not apply it and most likely will not be able to do that.
the describe output:
Table M_SIGN_INVENTORY:
Column name             Attribute type   Null?      Length,DPs    RowID Column?
-------------------------------------------------------------------------------
ASSEMBLY_TYPE           SE_STRING        NULL          100
SETUP_ASSEMBLY_STATUS   SE_INT32         NULL           10
ROUTE_ID                SE_INT32         NULL           10
REFLECT_TAPE            SE_INT32         NULL           10
DAMAGE                  SE_INT32         NULL           10
COMMENT_STR             SE_STRING        NULL         4000
DATE_INSTALLED          SE_DATE          NULL            0
GEOM                    SE_SHAPE         NULL            0
DATE_UPDATE             SE_DATE          NULL            0
SERIAL_NUM              SE_STRING        NULL           20
ROW_STATE               SE_STRING        NULL            1
OBJECTID                SE_INT32         NOT NULL       10        SDE Set
SIGN_ID                 SE_INT32         NULL           10
GLOBALID                SE_UUID          NOT NULL       38


I do not have 'C' parameter in my sdelayer. I noticed that without the C parameter it defaults to column [ObjectID] which is OK for my task. However, with C it might be more clear.

I need to do that in a script that will be delivered to a client. Putting it all to a script would be much nicer than asking client to do that in ArcCatalog.

Also, I was looking at sdetable command and code
sdetable -o add_uuid_column -t M_SIGN_INVENTORY -u %USERID%  -p %USERPASSWORD% -c GLOBALID


I thought it is the GLOBALID but after running the code above I still can add GLOBALID column via ArcCatalog, it creates [GLOBALID_1] field. However, a message box before creation of GlobalId says that it only be created when it does not already exist. That tells me that "add_uuid_column" is not GLOBALID.

Also, I start looking at PY scripts but I know nothing about python...
0 Kudos
VinceAngelo
Esri Esteemed Contributor
There are no ArcSDE command-line utilities to manage geodatabase objects.

If the table is viewed by ArcSDE as having a SE_UUID_TYPE, but ArcGIS does not
acknowledge it as a GlobalID, then you'll need to use either the ArcGIS GUI or ArcPy
to do the registration, though it's not obvious what that method might be -- Have
you tried a "register with geodatabase" after the ArcSDE layer registration and
'sdetable -o add_uuid_column'?

If you don't need to use existing values, then waiting until after geodatabase registration
is probably the path of least resistance.

- V
0 Kudos
AlexProtyagov
Emerging Contributor
I did try what you suggested:

sdelayer -o register -l M_SIGN_INVENTORY,GEOM -C OBJECTID -u %USERID% -p %USERPASSWORD% -e 3npM -x 0,0,3048 -z 0,10000 -P HIGH -t SDO_GEOMETRY -G file=%CRSFILE%

sdetable -o add_uuid_column -t M_SIGN_INVENTORY -u %USERID%  -p %USERPASSWORD% -c GLOBALID


The add_uuid_column, as I found, has nothing to do with GlobalID because after replication of feature layers the features are read-only which implies that GlobalId is not defined as esri sees that.

Last thing to try is a python script:
# Import system modules
import arcpy
from arcpy import env

# Set workspace
env.workspace = "C:/Data/MySDEdata.sde"

# Set local variables
in_dataset = "AMS_AA.M_SIGN_INVENTORY"

# Execute AddGlobalIDs
arcpy.AddGlobalIDs_management(in_dataset)


Where AMS_AA is schema name, [M_SIGN_INVENTORY] is feature class name, the same as Oracle table. However, the scrip above fails with error

ExecuteError: ERROR 000582: Error occurred during execution.
Failed to execute (AddGlobalIDs).


However, I do not know anything about python, I just took above script from documentation and replaced feature class name with mine.
0 Kudos
AlexProtyagov
Emerging Contributor
Ok, I got the python scrip working.

I changed

in_dataset = "AMS_AA.M_SIGN_INVENTORY"


to

in_dataset = "M_SIGN_INVENTORY"


and the connection file, MySDEdata.sde, copied it from my
c:\Users\xxxxxx\AppData\Roaming\ESRI\Desktop10.0\ArcCatalog\ams_aa.py. In connection properties I set to save user name and password in that file..
0 Kudos
HeatherMcCracken
Esri Contributor
fyi - In ArcObjects you can register a GUID field as a GlobalID field (or vice versa) using the IClassSchemaEditEx interface

http://help.arcgis.com/en/sdk/10.0/vba_desktop/componenthelp/index.html#/IClassSchemaEditEx_Interfac...
0 Kudos