Next_GlobalID

Definition

Next_GlobalID takes a table that is registered with the geodatabase as an input parameter and returns the next GlobalID value.

You can use this value when you are inserting a row to the table using SQL.

The globalID field is added to allow the table to participate in geodatabase replication. The Next_GlobalID function does not return values for other GUID fields.

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.

NoteNote:

To use the Next_GlobalID function in PostgreSQL, you must have the PostgreSQL uuid-ossp contrib module installed in the database where your geodatabase is stored.

To get the next GlobalID value in a SQL Server database, use the SQL Server newid() function.

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 the NextGlobalID function in each database in which it is supported.

Tables that are registered with the geodatabase contain ObjectID columns (RowIDs). Therefore, when you insert a record to a geodatabase table that contains a GlobalID column, you will also need to insert a RowID value.

The example for each database inserts a record into the sitings table owned by buse, and calls the Next_RowID procedure to insert a value to the ObjectID field, and the Next_GlobalID procedure to insert a value to the GlobalID field. In DB2, you must call the Next_RowID procedure first to get a value for the ObjectID field, then use that value in the insert statement, which includes the Next_GlobalID function to insert a value to the GlobalID 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 GlobalID field.

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 INTO buse.sitings (objectid, globalid, mon_type)
VALUES
(698, sde.next_globalid, 'golem');

The SQL command completed successfully

Oracle

INSERT INTO wuse.sitings (objectid, globalid, mon_type)
VALUES
(sde.gdb_util.next_rowid('WUSE', 'SITINGS'), sde.gdb_util.next_globalid, 'golem');

1 row created

PostgreSQL

INSERT INTO wuse.sitings (objectid, globalid, mon_type)
VALUES
(sde.next_rowid('wuse', 'sitings'), sde.next_globalid(), 'golem');

Query returned successfully: 1 row affected, 109 ms execution time.
6/19/2015