To obtain the last logical key added by an insert statement, issue the following inquire_sql statement:
exec sql inquire_sql
(:key_variable:null_indicator = key_type)
where:
key_type is object_key or table_key.
This inquiry must be issued after an insert that adds a single row containing a logical key. In the case of the insert...as select statement, inquire_sql(:row_variable=rowcount) can be used to determine the number of rows added. Inquire_sql cannot be used to obtain individual logical key values for multiple rows inserted as the result of an insert...as select statement.
A null indicator variable must be specified when inquiring about logical keys. Inquire_sql returns the following values:
| Null Indicator | Key Variable | Returned When.. | 
|---|---|---|
| 0 | Logical key value | Inquiry is issued after an insert statement that added a single row containing a system_maintained table or object key column. | 
| -1 | Unchanged | Inquiry is issued after: 
 | 
The following table lists the inquire_sql parameters that return information about a database event. All character values are returned in lower case. If no event is queued, an empty or blank string is returned (depending on your host language conventions).
| Object | Data Type | Description | 
|---|---|---|
| dbeventname | Character | The name of the event (assigned using the create dbevent statement). The receiving variable must be large enough for the full event name; if the receiving variable is too small, the event name is truncated to fit. | 
| dbeventowner | Character | The creator of the event. | 
| dbeventdatabase | Character | The database in which the event was raised. | 
| dbeventtime | Date | The date and time at which the event was raised. | 
| dbeventtext | Character | The text (if any) specified as the event_text parameter when the event was raised. The receiving value must be a 256-character string; if the receiving variable is too small, the text is truncated to fit. |