Mimer SQL Documentation TOC PREV NEXT INDEX

Mimer SQL Developer Site

http://developer.mimer.com


Connecting to a Database


Only idents of type USER and OS_USER can be used to connect to a Mimer SQL database. A connection is established using the CONNECT statement, with the general form:

 CONNECT TO 'DATABASE' [AS 'CONNECTION_NAME']
 USER 'USER_NAME' USING 'password';
 

This statement establishes a connection between the user and a database, see the Mimer SQL Reference Manual, Chapter 12, CONNECT, for details.

A connection may be established to any local or remote database, which has been made accessible from the current machine - see the Mimer SQL Systmen Management Handbook, chapter 3, Registering the Database, for details. The database can be specified by name or by using the keyword DEFAULT.

Note: If the keyword DEFAULT is used, a user and password cannot be specified. If you wish to connect to the default database and specify a user and password, specify an empty string ('') for the database.

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

An application program 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, the application 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, the application program 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



Upright Database Technology AB
Voice: +46 18 780 92 00
Fax: +46 18 780 92 40
dbtechnology@upright.se
Mimer SQL Documentation TOC PREV NEXT INDEX