DISCONNECT

Terminates database sessions when in multi-session mode.

Syntax

DISCONNECT { ALL | CURRENT | session }
  1. session is a string expression identifying the name of the database session to be terminated.

Usage

The DISCONNECT instruction closes a given database connection.

The session name is case-sensitive.

When using the DEFAULT keyword, it identifies the default database server connection established with a CONNECT TO DEFAULT or a DATABASE instruction. This clause is specific to IBM® Informix® databases.

Use the ALL keyword to terminate all opened connections. From that point, you must establish a new connection to execute SQL statements.

Use the CURRENT keyword to terminate the current connection only. From that point, in order to execute SQL statements, you must select another connection with SET CONNECTION, or establish a new connection with CONNECT TO.

A DISCONNECT statement cannot be executed with dynamic SQL (i.e. PREPARE + EXECUTE).

If a DISCONNECT statement is used while a database transaction is active, the transaction is automatically rolled back.

MAIN
  CONNECT TO  "stores1"  -- Will be identified by "stores1"
  CONNECT TO  "stores1" AS "SA"
  CONNECT TO  "stores2" AS "SB" USER "scott" USING "tiger"
  DISCONNECT "stores1"
  DISCONNECT "SB"
  SET CONNECTION "SA"
END MAIN