Previous Topic

Next Topic

Disconnect

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.

Previous Topic

Next Topic

Syntax

The Disconnect statement has the following format:

EXEC SQL DISCONNECT [CURRENT] | connection_name |[SESSION session_identifier | ALL];

Previous Topic

Next Topic

Permissions

All users are permitted to use this statement.

Previous Topic

Next Topic

Locking

When the Disconnect statement is issued, all locks held by the session are dropped.

Previous Topic

Next Topic

Related Statements

Connect

Set

Previous Topic

Next Topic

Examples: Disconnect

The following are Disconnect statement examples:

  1. Disconnect from the current database.

    exec sql disconnect;

  2. Disconnect a session in a multi-session application by specifying the connection name.

    exec sql disconnect accounting;

  3. Disconnect a session by specifying its session identifier.

    exec sql disconnect session 99;

  4. On an error, roll back pending updates, disconnect the database session.

    exec sql whenever sqlerror goto err;
    ...
    err:
    exec sql rollback;
    exec sql disconnect;


© 2007 Ingres Corporation. All rights reserved.