Previous Next

CURRENT-VALUE function
Returns the current INT64 value of a sequence defined in the Data Dictionary.
Syntax 
 
CURRENT-VALUE ( sequence [ , logical-dbname ] [ , tenant-id ] )
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 a sequence with this name exists in more than one connected database, then you must specify 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.
Example 
The following example finds the current value of the NextCustNum sequence and then looks for Orders with that Customer number:
 
DEFINE VARIABLE cur-cust NO-UNDO LIKE Customer.CustNum.
 
cur-cust = CURRENT-VALUE(NextCustNum).
IF CAN-FIND(FIRST Order WHERE Order.CustNum = cur-cust) THEN
FOR EACH Order NO-LOCK WHERE Order.CustNum = cur-cust, 
  EACH OrderLine OF Order NO-LOCK
  BREAK BY Order.OrderNum:
 
  IF FIRST-OF(Order.OrderNum) THEN
    DISPLAY Order.OrderNum Order.OrderDate Order.CustNum
      WITH FRAME order-info CENTERED ROW 2 1 COL.
   
  DISPLAY OrderLine.
END.
ELSE DO:
  FIND FIRST Customer WHERE Customer.CustNum = cur-cust NO-LOCK NO-ERROR.
  IF AVAILABLE Customer THEN
    MESSAGE "No Orders Exist for Customer " + Customer.Name +
      ", " + STRING(Customer.CustNum)
      VIEW-AS ALERT-BOX INFORMATION BUTTONS OK TITLE "No Orders".
  ELSE 
  MESSAGE "Customer number" cur-cust "does not exist."
    VIEW-AS ALERT-BOX INFORMATION BUTTONS OK TITLE "No Customer".
END.
Notes 
*
*
*
*
The Unknown value (?) if the sequence has exceeded its minimum or maximum and is not cycling
*
If sequence is a multi-tenant sequence in the database, each regular tenant has their own current value of the sequence. So, the same values are returned for each tenant that invokes this function. If the sequence is shared in a multi-tenant database, the values returned by this function are unique across all tenants in the database.
Caution:
*
*
*
*
See also 
CURRENT-VALUE statement, DYNAMIC-CURRENT-VALUE function, DYNAMIC-CURRENT-VALUE statement, DYNAMIC-NEXT-VALUE function, NEXT-VALUE function

Previous Next
© 2013 Progress Software Corporation and/or its subsidiaries or affiliates.