SYSCS_UTIL.SYSCS_PEEK_AT_IDENTITY system function

The SYSCS_UTIL.SYSCS_PEEK_AT_IDENTITY function allows users to observe the next value which will be issued for an identity column.

This function can be used in databases which have been fully upgraded to Derby Release 10.11 or higher. (See "Upgrading a database" in the Derby Developer's Guide for more information.) In a database which has been fully upgraded to Release 10.11 or higher, identity values are produced by internal, system-managed sequence generators. SYSCS_UTIL.SYSCS_PEEK_AT_IDENTITY allows users to observe the next identity value without having to query the SYSSEQUENCES system table.

This function has no meaning in a database which is at Release 10.10 or earlier.

Querying the SYSSEQUENCES system table does not actually return the current identity value; it only returns an upper bound on that value, that is, the end of the chunk of identity values which has been preallocated but not actually used. The SYSCS_UTIL.SYSCS_PEEK_AT_IDENTITY function shows you the very next value which will be inserted into a table. Users should never directly query the SYSSEQUENCES table, because that will cause sequence generator concurrency to slow drastically.

Syntax

BIGINT SYSCS_UTIL.SYSCS_PEEK_AT_IDENTITY(IN SCHEMANAME VARCHAR(128),
IN TABLENAME VARCHAR(128))

As with all system functions, schema and object name arguments are case-sensitive.

Execute privileges

By default, all users have execute privileges on this function.

Example

VALUES SYSCS_UTIL.SYSCS_PEEK_AT_IDENTITY('APP', 'orders');