Inserting a value into a global ID or GUID column in PostgreSQL using SQL

Global ID and GUID data types store registry-style strings consisting of 36 characters enclosed in curly brackets. These strings uniquely identify a feature or table row within a geodatabase and across geodatabases. Global IDs are used to maintain uniqueness of records in one-way and two-way geodatabase replicas. GUIDs can be added to any layer.

Therefore, if the table you want to edit participates in replication or contains a GUID, you must insert a unique value to the global ID or GUID column when you insert a new record in the table using SQL. To do this, use the retrieve_guid() function to edit a multiversioned view of the table using SQL.

TipTip:

You can add global IDs to a feature class in the Catalog window by right-clicking the dataset and clicking Add Global IDs. The geodatabase maintains these values automatically when editing through ArcGIS.

Steps:
  1. If you are editing a versioned table, create a multiversioned view of it as described in Creating multiversioned views.
  2. If you are editing a versioned table, follow the instructions in Editing versioned data in PostgreSQL using multiversioned views and SQL to create a version for editing, set the version, then start an edit session. If you are editing a nonversioned table, proceed to the next step.
  3. When inserting a record, use the retrieve_guid() function to insert the next global ID or GUID value.
    INSERT INTO jason.asset_mv (asset_id,globalid) 
    VALUES (57,sde.retrieve_guid());
    
  4. When you finish editing, stop the edit session as described in Editing versioned data in PostgreSQL using multiversioned views and SQL if you were editing a versioned table.

2/5/2013