Valid in: ESQL
The Disconnect statement terminates a session connected to a database. The disconnect statement implicitly closes any open cursors, and commits any pending updates.
To disconnect a session other than the current session in a multi-session application, specify the session session_identifier clause or the connection name. (Connection names and session identifiers are specified using the connect statement.) To determine the numeric session identifier for the current session, use the inquire_sql(:session_id = session) statement.
To determine the connection name for the current session, use the inquire_sql(connection_name) statement. If an invalid session is specified, the DBMS Server issues an error and does not disconnect the session.
To disconnect all open sessions, specify disconnect all.
The Disconnect statement has the following format:
EXEC SQL DISCONNECT [CURRENT] | connection_name |[SESSION session_identifier | ALL];
All users are permitted to use this statement.
When the Disconnect statement is issued, all locks held by the session are dropped.
The following are Disconnect statement examples:
exec sql disconnect;
exec sql disconnect accounting;
exec sql disconnect session 99;
exec sql whenever sqlerror goto err;
...
err:
exec sql rollback;
exec sql disconnect;