Try OpenEdge Now
skip to main content
SQL Reference
SQL Reference : OpenEdge SQL Functions : CURRVAL
 

CURRVAL

CURRVAL returns the current value of a sequence, and uses the following syntax to reference the current value of a sequence.

Syntax

schema.sequence. CURRVAL

Parameters

schema
Specifies the schema that contains the sequence. To refer to the current value of a sequence in the schema of another user, you must have SELECT object privilege on the sequence.
sequence
Specifies the name of the sequence whose current value you want.
Use CURRVAL in:
*The SELECT list of a SELECT statement not contained in a subquery or view
*The SELECT list of a subquery in an INSERT statement
*The VALUES clause of an INSERT statement
*The SET clause of an UPDATE statement
CURRVAL cannot be used in:
*A query of a view
*A SELECT statement with a GROUP BY clause that references a sequence
*A SELECT statement with an ORDER BY clause that references a sequence
*A SELECT statement that is combined with another SELECT statement with the UNION, INTERSECT, or MINUS set operator
*The WHERE clause of a SELECT or UPDATE statement
*The DEFAULT value of a column in a CREATE TABLE or ALTER TABLE statement
*The condition of a CHECK constraint

Example

In the following example, the OpenEdge SQL sequence generator returns the current value of the customer sequence:
SELECT customer_sequence.CURRVAL FROM pub.customer;