Mimer SQL Documentation TOC PREV NEXT INDEX

Mimer SQL Developer Site


BSQL and Multiple Connections


After logging in using BSQL, additional connections can be established using the CONNECT statement, which has the following form:

 CONNECT TO 'database' [AS 'connection_name']
   USER 'username' USING 'password';
 

This statement establishes a new connection between the user and a database, see the Mimer SQL Reference Manual, CONNECTfor details.

The database may be given an explicit connection name for use in DISCONNECT and SET CONNECTION statements. If no explicit connection name is specified, the database name is used as the connection name.

Changing Connections

BSQL may make multiple connections to the same or different databases using the same or different idents, provided that each connection is identified by a unique connection name. In this situation only one connection is active and the other connections are inactive. A connection established by a successful CONNECT statement is automatically active.

A connection may be made active by the SET CONNECTION statement.

For example:

 SET CONNECTION 'connection_name';

Disconnecting

The DISCONNECT statement breaks the connection between the user and a database. The connection to be broken is specified as the connection name or as one of the keywords ALL, CURRENT or DEFAULT.

 DISCONNECT 'connection_name';
 

A connection does not have to be active in order to be disconnected. If an inactive connection is broken, BSQL still has uninterrupted access to the database through the current (active) connection, but the broken connection is no longer available for activation with SET CONNECTION.

If the active connection is broken, BSQL cannot access any database until a new CONNECT or SET CONNECTION statement is issued.

Note: The distinction between breaking a connection with DISCONNECT and making a connection inactive by issuing a CONNECT or SET CONNECTION for a different connection is, a broken connection has no saved resources and cannot be reactivated by SET CONNECTION.

The table below summarizes the effect on the connection con1 of CONNECT, DISCONNECT and SET CONNECTION statements depending on the state of the connection.

Statement
con1 non-existent
con1 current
con1 inactive
CONNECT TO 'DB1' AS 'CON1'
con1 current
error - connection already exists
error - connection already exists
DISCONNECT 'CON1'
error - connection doesn't exist
con1 disconnected
con1 disconnected
SET CONNECTION 'CON1'
error - connection doesn't exist
ignored
con1 made current
CONNECT TO 'DB2' AS 'CON2'
-
con1 made inactive
con1 unaffected
DISCONNECT 'CON2'
-
con1 unaffected
con1 unaffected
SET CONNECTION 'CON2'
-
con1 made inactive
con1 unaffected


Mimer
Mimer Information Technology AB
Voice: +46 18 780 92 00
Fax: +46 18 780 92 40
info@mimer.se
Mimer SQL Documentation TOC PREV NEXT INDEX