Resets the current integer value of a sequence
defined in the Data Dictionary.
Syntax
CURRENT-VALUE ( sequence[ , logical-dbname][ , tenant-id ] ) = expression
|
-
sequence
- An identifier that specifies the name of a sequence defined
in the Data Dictionary.
-
logical-dbname
- An identifier that specifies the logical name of the database
in which the sequence is defined. The database must be connected.
You can omit this parameter if the sequence name is unambiguous.
If more than one connected database has a sequence with given name,
then you must supply logical-dbname.
-
tenant-id
- An integer expression that evaluates to the tenant ID of a regular tenant,
including the default tenant (0). This option applies
only to a multi-tenant sequence specified by sequence and
is intended for access primarily by a super-tenant user.
If you
are a regular-tenant user and you specify tenant-id,
the specified tenant must be the same as the tenant associated with
the database connection identity for logical-dbname or
the AVM raises a run-time error.
If you are a super-tenant
user and you do not specify tenant-id, the function
assumes the effective tenant ID (GET-EFFECTIVE-TENANT-ID function).
If the sequence specified by sequence is non-multi-tenant
(a shared sequence in a multi-tenant database), and you specify tenant-id,
the option is ignored.
-
expression
- An integer expression assigned as the current value of the specified sequence.
If expression is outside the boundary set by
the initial value (at one end) and the lower limit or upper limit
(at the other end) for the sequence, the AVM returns an error, and
the sequence value remains unchanged.
Example
The
following example resets the current value of the NextCustNum sequence
to the CustNum value of the last Customer record
if that is a valid value for the sequence:
r-curvl1.p
FIND LAST customer NO-LOCK.
IF Customer.CustNum < CURRENT-VALUE(NextCustNum) AND
Customer.CustNum > 1000 THEN DO:
CURRENT-VALUE(NextCustNum) = Customer.CustNum.
MESSAGE "The value of NextCustNum has been changed to"
Customer.CustNum VIEW-AS ALERT-BOX INFORMATION BUTTONS OK.
END.
ELSE
MESSAGE "The value of NextCustNum remains"
CURRENT-VALUE(NextCustNum) VIEW-AS ALERT-BOX INFORMATION BUTTONS OK.
|
Notes
- The
user must have CAN-WRITE privileges on the _Sequence table to use
the CURRENT-VALUE statement.
- The value of a sequence set by the CURRENT-VALUE statement persists
in the database until the next CURRENT-VALUE statement or NEXT-VALUE
function is invoked for the sequence, or until the sequence is deleted
from the database.
- You cannot set a sequence to the Unknown value (?).
- If sequence is a multi-tenant sequence in
the database, each regular tenant has their own current value of
the sequence. So, each tenant that invokes this statement can set
their own current values, which can be the same or different than
the current values set by other tenants. If the sequence is shared
in a multi-tenant database, any current value set by this statement
is shared by all tenants in the database.
Caution:
Be
very careful using multi-tenant sequences when you are updating
shared tables or multi-tenant tables for a tenant group. For more
information, see the sections on using multi-tenant-enabled sequences in OpenEdge
Development: Programming Interfaces
- You can use any combination of the NEXT-VALUE function, CURRENT-VALUE
function, CURRENT-VALUE statement, and their dynamic versions. Use
the dynamic version when you don't know what the database name or
sequence name is at compile time.