Previous Topic

Next Topic

Connection Using a Connection Name

A simple CONNECT statement accepts the database name and the connection name as arguments to make a valid connection. The format for this statement is as shown:

EXEC SQL
 CONNECT TO database_name AS connection_name ;

For example, to connect to a database custdb using the connection name conn_1, the statement would be:

EXEC SQL
 CONNECT TO 'custdb' AS 'conn_1' ;

The connection name, conn_1, has to be unique. If the connection name is not specified, then the database name is taken as the connection name. For example, consider the above example without the connection name specification:

EXEC SQL
 CONNECT TO 'custdb' ;

Here the connection name is taken to be custdb.