sa_conn_activity system procedure

Returns the most recently-prepared SQL statement for each connection to the specified database on the server.

Syntax

sa_conn_activity( [ connidparm ] )

Arguments

Result set

Column name Data type Description
Number INT

Returns the ID number of the connection.

Name VARCHAR(255)

Returns the name of the current connection.

Temporary connection names have INT: prepended to the connection name.

Userid VARCHAR(255)

Returns the user ID for the connection.

DBNumber INT

Returns the ID number of the database.

LastReqTime VARCHAR(255)

Returns the time at which the last request for the specified connection started. This property can return an empty string for internal connections, such as events.

LastStatement LONG VARCHAR

Returns the most recently prepared SQL statement for the current connection.

Remarks

The sa_conn_activity system procedure returns a result set consisting of the most recently-prepared SQL statement for each connection, if the server has been told to collect the information. Recording of statements must be enabled for the database server before calling sa_conn_activity. To do this, specify the -zl option when starting the database server, or execute the following:

CALL sa_server_option('RememberLastStatement','ON');

This procedure is useful when the database server is busy and you want to obtain information about the last SQL statement prepared for each connection. This feature can be used as an alternative to request logging.

If connidparm is not specified, then information is returned for all connections to all databases running on the database server. If connidparm is less than zero, option values for the current connection are returned.

Because of tenant database isolation rules, when this system procedure is run in the cloud it returns only information about the current tenant database.

Permissions

None

Side effects

None