SYSCS_UTIL.SYSCS_PEEK_AT_SEQUENCE Function

The SYSCS_UTIL.SYSCS_PEEK_AT_SEQUENCE function allows users to observe the instantaneous current value of a sequence generator without having to query the  SYSSEQUENCES system table.

Querying the SYSSEQUENCES table does not actually return the current value; it only returns an upper bound on that value, which is the end of the chunk of sequence values that has been pre-allocated but not yet used.

The SYSCS_UTIL.SYSCS_PEEK_AT_SEQUENCE function shows you the very next value that will be returned by a NEXT VALUE FOR clause. 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_SEQUENCE(
            IN SchemaName VARCHAR(128),
            IN SequenceName VARCHAR(128)
)

SchemaName

The name of the schema.

SequenceName

The name of the sequence.

Results

Returns the next value that will be returned for the sequence.

Execute Privileges

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

Example

splice> VALUES SYSCS_UTIL.SYSCS_PEEK_AT_SEQUENCE('SPLICE', 'PlayerID_seq');

See Also