ArcGIS Desktop

  • ArcGIS Pro
  • ArcMap

  • My Profile
  • Help
  • Sign Out
ArcGIS Desktop

ArcGIS Online

The mapping platform for your organization

ArcGIS Desktop

A complete professional GIS

ArcGIS Enterprise

GIS in your enterprise

ArcGIS Developers

Tools to build location-aware apps

ArcGIS Solutions

Free template maps and apps for your industry

ArcGIS Marketplace

Get apps and data for your organization

  • Documentation
  • Support
Esri
  • Sign In
user
  • My Profile
  • Sign Out

ArcMap

  • Home
  • Get Started
  • Map
  • Analyze
  • Manage Data
  • Tools
  • Extensions

Next_GlobalID

  • Definition
  • Syntax
  • Return type
  • Examples

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.

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'
 );
Tip:

If you don't want to get the next globalID value before inserting it to the table, you can use the SQL Server newid() function directly in the insert statement, as shown in Inserting a value into a Global ID column in SQL Server using SQL.

Related topics

  • GlobalID_Name
  • Insert a value into a global ID or GUID column in Db2 using SQL
  • Inserting a value into a global ID or GUID column in Oracle using SQL
  • Inserting a value into a global ID or GUID column in PostgreSQL using SQL

ArcGIS Desktop

  • Home
  • Documentation
  • Support

ArcGIS

  • ArcGIS Online
  • ArcGIS Desktop
  • ArcGIS Enterprise
  • ArcGIS
  • ArcGIS Developer
  • ArcGIS Solutions
  • ArcGIS Marketplace

About Esri

  • About Us
  • Careers
  • Esri Blog
  • User Conference
  • Developer Summit
Esri
Tell us what you think.
Copyright © 2021 Esri. | Privacy | Legal