Definition
Next_GlobalID takes a table that is registered with the geodatabase as an input parameter and returns the next global ID value.
You can use this value when you are inserting a row to the table using SQL.
The global ID field is added to allow the table to participate in geodatabase replication or offline mapping.
You can use this value when you are inserting a row to the table using SQL.
An error is returned if the input table is not registered with the geodatabase.
Syntax
<geodatabase administrator schema>.next_globalid (<table owner>, <table name>)
In most geodatabases, the geodatabase administrator schema is sde. However, it is dbo in dbo-schema geodatabases in SQL Server, and in user-schema geodatabases in Oracle, it is the name of the user's schema.
Return type
String
Examples
The following are examples of using Next_GlobalID in each database in which it is supported.
The example for each database inserts a record into the sitings table owned by buse, calls Next_RowID to insert a value to the ObjectID field, and calls Next_GlobalID to insert a value to the global ID field.
DB2
Since geodatabase tables include a non-null ObjectID field, you must first get a value to insert to that field. In the following example, the next RowID value is obtained for the ObjectID field (698), then a record is inserted to the table that includes the next RowID value and the Next_GlobalID function to insert a value to the global ID field.
--Get the next ObjectID value.
CALL sde.next_rowid('BUSE', 'SITINGS', ?, ?, ?);
Value of output parameters
Parameter Name : O_ROWID
Parameter Value : 698
Parameter Name : O_MSGCODE
Parameter Value : 0
Parameter Name : O_MESSAGE
Parameter Value : Procedure successfully completed.
Return Status = 1
--Insert the ObjectID from the previous statement to the objectid field.
--Use the Next_GlobalID function to insert a value to the globalid field.
INSERT INTO buse.sitings (objectid, globalid, mon_type)
VALUES (
698,
sde.next_globalid,
'golem'
);
The SQL command completed successfully
Oracle
You can include the Next_GlobalID utility in the insert statement to insert the next available ID value. The following example also uses the Next_RowID utility to insert a value to the ObjectID field, which is present in all geodatabase tables and must be populated.
INSERT INTO buse.sitings (objectid, globalid, mon_type)
VALUES (
sde.gdb_util.next_rowid('BUSE', 'SITINGS'),
sde.gdb_util.next_globalid,
'golem'
);
1 row created
PostgreSQL
You can include the Next_GlobalID function in the insert statement to insert the next available ID value. The following example also uses the Next_RowID function to insert a value to the ObjectID field, which is present in all geodatabase tables and must be populated.
INSERT INTO buse.sitings (objectid, globalid, mon_type)
VALUES (
sde.next_rowid('buse', 'sitings'),
sde.next_globalid(),
'golem'
);
Query returned successfully: 1 row affected, 109 ms execution time.
SQL Server
Next_GlobalID and Next_RowID are stored procedures, which must be run outside your INSERT statement to obtain the next ID values. Both are stored in the geodatabase administrator's schema. In the following example, the geodatabase administrator is sde. The values returned from these stored procedures are used in the INSERT statement to update the sitings table.
--Get the next ObjectID value.
DECLARE @oid int
EXEC sde.next_rowid 'buse', 'sitings', @oid OUTPUT
SELECT @oid "ObjectID value";
ObjectID value
98765
--Get the next global ID value.
DECLARE @gid uniqueidentifier
EXEC sde.next_globalid @gid OUTPUT
SELECT @gid "ID value";
ID value
0D5D0605-8954-4A65-B86C-D2DA96C2D0C5
--Insert a row to the sitings table.
INSERT INTO buse.sitings (objectid, globalid, mon_type)
VALUES (
98765,
'0D5D0605-8954-4A65-B86C-D2DA96C2D0C5',
'golem'
);