The mi_last_serial() function
The mi_last_serial() function returns a SERIAL value that the database server has generated for the most recent INSERT statement on a SERIAL column.
Syntax
mi_integer mi_last_serial(conn, serial_val)
MI_CONNECTION *conn;
mi_integer *serial_val;
- conn
- A pointer to a connection descriptor established by a previous call to mi_open(), mi_server_connect(), or mi_server_reconnect().
- serial_val
- A pointer to the new SERIAL value to obtain.
Valid in client LIBMI application? | Valid in user-defined routine? |
---|---|
Yes | Yes |
Usage
The database server automatically generates a value for a SERIAL column when it executes an INSERT statement on the column.
Server only: Use the mi_last_serial() function
to obtain the last system-generated SERIAL value for your C user-defined
routine.
Client only: To use the mi_last_serial() function
in a client LIBMI application, call it after the insert operation
is complete (when the mi_get_result() function
returns the MI_DML statement).
You must also call mi_last_serial() before any call to mi_query_finish() or mi_close().
Return values
- MI_OK
- The function was successful.
- MI_ERROR
- The function was not successful.