CONNECT statement

Use the CONNECT statement to connect to a database environment. This statement is an extension to the ANSI/ISO standard for SQL.

Syntax

(1)
Notes:

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. The 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 HCL OneDB™ 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 statement.

For connections between databases of different HCL OneDB instances, you cannot establish multiple active connections between the same two database servers using different server aliases. At any time, there can be only one active connection from the local server to a remote server. If you use CONNECT TO dbserveralias statements to specify different server aliases to connect to the same remote server, where the dbserveralias identifiers are declared in setting of the DBSERVERALIASES configuration parameter setting, no error message is issued, but the initial connection is reused.