CURRVAL

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

Specifies a schema, by default public. If schema is any schema other than public, you must supply the schema name. For example:

myschema.thisDbObject

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