GETAUTOINCVALUE( ) Function
Returns the last value generated for an autoincremented field within a data session.
GETAUTOINCVALUE([nDataSessionNumber | 0])
Parameters
nDataSessionNumber
Specifies the data session number of the data session for which the autoincremented field value is returned.The autoincremented field value is returned for the current data session if you omit the nDataSessionNumber and 0 parameters.
Use SET DATASESSION to activate a specific data session.
- 0
Specifies that the last autoincremented field value returned is derived from the current scope (function, method, procedure). Use this to prevent events outside of that current code block, such as ON KEY LABEL, from executing code that could alter the value unexpectedly.
Return Value
Numeric data type. The value returned by GETAUTOINCVALUE( ) is the last autoincrement value generated, even if a field was not successfully updated with the autoincrement value. .NULL. is returned if an autoincrement value hasn't yet been generated for a data session. For example, .NULL. is returned if a data session is opened and no updates have occurred.
Remarks
The autoincremented field value is updated for table operations such as APPEND Command, INSERT Command, APPEND FROM Command, and BLANK Command when the AUTOINC option is included. See Autoincrementing Field Values in Tables for more information about autoincrementing fields.