Enterprise Edition Home | Express Edition Home | Previous Page | Next Page   SQL Statements >

CONNECT

Use the CONNECT statement to connect to a database environment.

This statement is an extension to the ANSI/ISO standard for SQL.

Syntax

Read syntax diagramSkip visual syntax diagram>>-CONNECT TO--------------------------------------------------->
 
                              (1)
>--+-| Database Environment |-------+-------------------------------+--+-----------------------------+-+-->
   |                                |  (2)                          |  |  (3)                   (4)  | |
   |                                '--------AS--+-'connection'---+-'  '--------| USER Clause |------' |
   |                                             '-connection_var-'                                    |
   '-DEFAULT-------------------------------------------------------------------------------------------'
 
>--+------------------------------------+----------------------><
   |  (2)                               |
   '--------WITH CONCURRENT TRANSACTION-'
 
Notes:
  1. See Database Environment
  2. ESQL/C only
  3. ESQL/C and DB-Access only
  4. See USER Clause
Element Description Restrictions Syntax
connection Case-sensitive name that you declare here for a connection Must be unique among connection names Quoted String
connection_var Host variable that stores the name of connection Must be a fixed-length character data type Language specific

Usage

The CONNECT statement connects an application to a database environment, which can be a database, a database server, or a database and a database server. If the application successfully connects to the specified database environment, the connection becomes the current connection for the application. SQL statements fail if the application has no current connection to a database server. If you specify a database name, the database server opens that database. You cannot include CONNECT within a PREPARE statement.

An application can connect to several database environments at the same time, and it can establish multiple connections to the same database environment, provided each connection has a unique connection name.

On UNIX, the only restriction on establishing multiple connections to the same database environment is that an application can establish only one connection to each local server that uses the shared-memory connection mechanism. To find out whether a local server uses the shared-memory connection mechanism or the local-loopback connection mechanism, examine the $INFORMIXDIR/etc/sqlhosts file. For more information on the sqlhosts file, refer to your IBM Informix Administrator's Guide.

On Windows, the local connection mechanism is named pipes. Multiple connections to the local server from one client can exist.

Only one connection is current at any time; other connections are dormant. The application cannot interact with a database through a dormant connection. When an application establishes a new connection, that connection becomes current, and the previous current connection becomes dormant. You can make a dormant connection current with the SET CONNECTION statement. See also SET CONNECTION.

Enterprise Edition Home | Express Edition Home | [ Top of Page | Previous Page | Next Page | Contents | Index ]