8. SQL Statements : CONNECT : Creating Multiple Sessions : Using Connection Names
 
Share this page                  
Using Connection Names
To assign a name to a connection, specify the AS clause. For example:
EXEC SQL CONNECT act107b AS 'accounting';
assigns the name, accounting, to the connection to the act107b database. To switch sessions using the connection name, use the SET CONNECTION statement. For example:
EXEC SQL SET CONNECTION 'accounting';
If the AS clause is omitted, the DBMS Server assigns a default connection name--the database specified in the CONNECT statement. This connection name can be used in subsequent SET CONNECTION statements to switch sessions. If the AS clause is omitted and a numeric session identifier is specified (using the SESSION clause), the default connection name is “iin,” where n is the specified numeric session identifier.
To determine the connection name for the current session, use the INQUIRE_SQL(CONNECTION_NAME) statement.