sa_conn_activity system procedure

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

Syntax

sa_conn_activity( [ connidparm ] )

Arguments

Result set

Column name Data type Description
Number INTEGER

Returns the connection ID (a number) for the current 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 INTEGER

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

If connidparm is less than zero, then information for the current connection is returned. If connidparm is not supplied or is NULL, then information is returned for all connections to all databases running on the database server.

The sa_conn_activity system procedure returns a result set consisting of the most recently-prepared SQL statement for the connection. 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.

Privileges

No privileges are required to execute this system procedure for the current connection ID. To execute this system procedure for other connections, you must have either the SERVER OPERATOR, MONITOR, or DROP CONNECTION system privilege.

Side effects

None

Example

The following example uses the sa_conn_activity system procedure to display the most recently-prepared SQL statement for each connection.

CALL sa_conn_activity( );
Number Name Userid DBNumber ...
1,949 SQL_DBC_117acc40 DBA 0 ...
1,948 setup User1 0 ...
... ... ... ... ...