| 
       CURRENT-VALUE ( sequence  , logical-dbname   , tenant-id  )
       | 
| 
       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. | 
 The current value of a sequence can be one of the following:
The current value of a sequence can be one of the following:
   The initial value specified in the Data Dictionary
The initial value specified in the Data Dictionary
   The last value set with either the CURRENT-VALUE statement or the NEXT-VALUE function
The last value set with either the CURRENT-VALUE statement or the NEXT-VALUE function
   The Unknown value (?) if the sequence has exceeded its minimum or maximum and is not cycling
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.
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.
   Sequence values are stored in the database in which they are defined, and persist between each invocation of the CURRENT-VALUE statement or NEXT-VALUE function.
Sequence values are stored in the database in which they are defined, and persist between each invocation of the CURRENT-VALUE statement or NEXT-VALUE function.
   You cannot invoke the CURRENT-VALUE function from within a WHERE clause. Doing so generates a compiler error. To use a result from the CURRENT-VALUE function in a WHERE clause, assign the result to a variable, then use the variable in the WHERE clause.
You cannot invoke the CURRENT-VALUE function from within a WHERE clause. Doing so generates a compiler error. To use a result from the CURRENT-VALUE function in a WHERE clause, assign the result to a variable, then use the variable in the WHERE clause.
   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.
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.
   Be careful when accessing a database sequence with an alias that points to a different database than the one used when the alias was defined. If you supply an alias name to the CURRENT-VALUE function or the NEXT-VALUE function, only the database used to define the alias is referenced. In this case, it is preferable to use the DYNAMIC-CURRENT-VALUE function and DYNAMIC-NEXT-VALUE function instead of the CURRENT-VALUE function and NEXT-VALUE function, respectively.
Be careful when accessing a database sequence with an alias that points to a different database than the one used when the alias was defined. If you supply an alias name to the CURRENT-VALUE function or the NEXT-VALUE function, only the database used to define the alias is referenced. In this case, it is preferable to use the DYNAMIC-CURRENT-VALUE function and DYNAMIC-NEXT-VALUE function instead of the CURRENT-VALUE function and NEXT-VALUE function, respectively.