DISCONNECT statement [ESQL] [Interactive SQL]

Use this statement to drop the current connection to a database.

Syntax
DISCONNECT [ connection-name | CURRENT | ALL ]
connection-name : identifier, string, or hostvar
Remarks

The DISCONNECT statement drops a connection with the database server and releases all resources used by it. If the connection to be dropped was named on the CONNECT statement, the name can be specified. Specifying ALL will drop all the application's connections to all database environments. CURRENT is the default, and will drop the current connection.

Before closing the database connection, Interactive SQL automatically executes a COMMIT statement if the commit_on_exit option is set to On. If this option is set to Off, Interactive SQL performs an implicit ROLLBACK. By default, the commit_on_exit option is set to On.

For information about dropping connections other than the current connection, see DROP CONNECTION statement.

This statement is not supported in procedures, triggers, events, or batches.

Permissions

None.

Side effects

None.

See also
Standards and compatibility
  • SQL/2003   SQL/foundation feature outside core SQL.

Example

The following statement shows how to use DISCONNECT in embedded SQL:

EXEC SQL DISCONNECT :conn_name

The following statement shows how to use DISCONNECT from Interactive SQL to disconnect all connections:

DISCONNECT ALL;