GlobalID COLUMN

4241
8
12-10-2010 12:25 PM
AlexProtyagov
New 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
8 Replies
AkhilParujanwala
New Contributor III
Uhm, Correct me if I am wrong, but by using ArcCatalog to manually add GlobalIDs it will also general the numbers too for the features that already exist.

If you do it by code it may not work? Does spelling of the column name matter too, like all caps vs uppper and lower case?.
0 Kudos
AlexProtyagov
New Contributor
Yes, when manually adding GlobalId via ArcCatalog GUI it does generate values for that column.

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 I running that 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
AkhilParujanwala
New Contributor III
Hmm, yah I see what your saying. I can't remember correctly but if you Manually add Global ID twice through ArcCatalog you will get the same result, GlobalID and GlobalID_1.

How many feature classes need to have global ids? Is is a lot or just a few, you may want to bite the bullet and tell your client to manually do it and once your do it, its done forever. Not like you will run the script again and again, unless your still developing something?
0 Kudos
AlexProtyagov
New Contributor
Currently not many, so it looks like I might at the end ask client to add GlobalID manually.

I was able to verify that command
sdetable -o add_uuid_column -t M_SIGN_INVENTORY -u %USERID%  -p %USERPASSWORD% -c GLOBALID

has nothing to do with GlobalID because everything in application, after I Sync Down feature layers is read-only which implies that GlobalId is not defined.

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).
0 Kudos
AkhilParujanwala
New Contributor III
Ok here is what I found based on your error

NIM037999 - Import Replica Schema gp tool fails: ERROR 000582: Error occurs during execution when trying to import schema changes.

This is as per this document:
http://www.esriaustralia.com.au/esri/ArcGIS_9_3_1_-_Issues_resolved_list.pdf

In my opinion what's happening is your trying to change the feature class in code, and it doesn't like that. Try a different field name other than GlobalID and see if that gets added. Another thig is if you have ArcMap open with that feature class or don't cloick on that feature class in ArcCatalog and then run your script.

If none of these suggestions work, then you might be SOL unless someone else has done this and is willing to share.
0 Kudos
AlexProtyagov
New Contributor
I finally got the py script working.
I changed
in_dataset = "AMS_AA.M_SIGN_INVENTORY"

to
in_dataset = "M_SIGN_INVENTORY"


I think py script is the only way to create GlobalId other than GUI.

Thank you for your replies.
0 Kudos
AkhilParujanwala
New Contributor III
Good Job 🙂 How's your client going to run the script?
0 Kudos
AlexProtyagov
New Contributor
Script creates connection, .sde file. Client would have to put his credentials in there and then execute the script. However, I am thinking about creating a feature class from existing oracle table in the python script. If I could do that I would not need batch file that runs sdelayer commands on ArcSDE server.
Made new thread :
http://forums.arcgis.com/threads/19366-sdelayer-command-in-Python
0 Kudos