HP 3000 Manuals

DISCONNECT [ ALLBASE/SQL Reference Manual ] MPE/iX 5.5 Documentation


ALLBASE/SQL Reference Manual

DISCONNECT 

The DISCONNECT statement terminates a connection with a DBEnvironment or
terminates all DBEnvironment connections established within an
application or an ISQL session.

Scope 

ISQL or Application Programs

SQL Syntax 

           {'ConnectionName'   }
           {'DBEnvironmentName'}
DISCONNECT {:HostVariable      }
           {ALL                }
           {CURRENT            }
Parameters 

ConnectionName          is a string literal identifying the name
                        associated with this connection.  ConnectionName 
                        must be unique for each DBEnvironment connection
                        within an application (or ISQL). ConnectionName 
                        cannot exceed 128 bytes.

'DBEnvironmentName'     is the DBEnvironment to which you have connected
                        to using a CONNECT TO 'DBEnvironmentName'
                        statement.

HostVariable            is a character string host variable containing
                        the ConnectionName associated with this
                        connection.

ALL                     specifies that all DBEnvironment connections in
                        effect (for an application or an ISQL session)
                        are to be terminated.

CURRENT                 specifies that the current connection is to be
                        terminated.  Within an application (or ISQL), the
                        current connection to a DBEnvironment is set by
                        the most recent statement that connects to or
                        sets the connection to the DBEnvironment.  If
                        there is no current connection in effect, an
                        error is generated.

Description 

   *   If a ConnectionName refers to a DBEnvironment that is not the one
       associated with the current connection, the specified connection
       is terminated, and the context of the currently connected
       DBEnvironment remains unchanged.

   *   Any active transaction associated with a connection is rolled back
       before the connection is terminated.

   *   No stored section is created for the DISCONNECT statement.
       DISCONNECT cannot be used with the PREPARE or EXECUTE IMMEDIATE
       statements.

   *   An active transaction is not required to execute a DISCONNECT
       statement.  An automatic transaction will not be started when
       executing a DISCONNECT statement.

   *   Any connection name associated with a disconnected connection can
       be reused.

   *   A DISCONNECT CURRENT statement is equivalent to a RELEASE
       statement.[REV BEG]

   *   Following a RELEASE or DISCONNECT CURRENT command, there is no
       current connection until a SET CONNECTION command is used to set
       the current connection to another existing connection, or a new
       connection is established by using the CONNECT, START DBE, START
       DBE NEW, or START DBE NEW LOG commands.[REV END]

Authorization 

You do not need authorization to use the DISCONNECT statement.

Example 

Connect three times to PartsDBE and once to SalesDBE:

     CONNECT TO :PartsDBE AS 'Parts1'
     CONNECT TO :PartsDBE AS 'Parts2'
     CONNECT TO :PartsDBE AS 'Parts3'
     CONNECT TO :SalesDBE AS 'Sales1'
     :

Terminate the connection associated with connection name Parts1:

      DISCONNECT 'Parts1' 

Terminate the connection associated with the most recently connected
DBEnvironment (the current connection).  Following the execution of this
statement, SalesDBE is no longer connected, and no current connection
exists:

      DISCONNECT CURRENT 

Note that another DISCONNECT CURRENT statement at this point would
generate an error.  Also any SQL statement that operates on a transaction
will fail since there is no current connection and therefore no current
transaction.

Set the current connection to Parts3:

      SET CONNECTION 'Parts3' 

Terminate the connection associated with the most recently connected DBE
(the current connection).  Following the execution of this statement, the
Parts3 connection to PartsDBE no longer exists, and no current connection
exists:

      DISCONNECT CURRENT 

Terminate all established connections.  Following this statement, the
Parts2 connection to PartsDBE no longer exists:

      DISCONNECT ALL 



MPE/iX 5.5 Documentation