CURRVAL

Returns the last value across all nodes that was set by NEXTVAL on this sequence in the current session.

Returns the last value across all nodes that was set by NEXTVAL on this sequence in the current session. If NEXTVAL was never called on this sequence since its creation, Vertica returns an error.

Syntax

CURRVAL ('[[database.]schema.]sequence-name')

Parameters

[database.]schema

Database and schema. The default schema is public. If you specify a database, it must be the current database.

sequence-name
The target sequence

Privileges

  • SELECT privilege on sequence

  • USAGE privilege on sequence schema

Restrictions

You cannot invoke CURRVAL in a SELECT statement, in the following contexts:

  • WHERE clause

  • GROUP BY clause

  • ORDER BY clause

  • DISTINCT clause

  • UNION

  • Subquery

You also cannot invoke CURRVAL to act on a sequence in:

  • UPDATE or DELETE subqueries

  • Views

Examples

See Creating and using named sequences.

See also

NEXTVAL