Switches the application from one established connection to another. This resumes the connection associated with the specified connection_name, restoring the context of that database connection to the same state it was in when suspended.
Syntax
SET CONNECTION { 'connection_name' | DEFAULT } ;
Parameters
connection_name
The name of the connection as either a character literal or host variable. If the SET CONNECTION statement omits a connection name, the default is the name of the database. Connection names must be unique.
DEFAULT
Sets the DEFAULT connection as the current connection.
Example
The first example shows how to establish a database as the current database:
EXEC SQL
SET CONNECTION 'conn_1' ;
The SET CONNECTION command sets the database associated with the connection named conn_1 to the status of current database. The connection named conn_1 must be associated with an established connection. Use SET CONNECTION DEFAULT to set current the database associated with the DEFAULT connection. In this example, the statement suspends the conn_1 connection, which had been current:
EXEC SQL
SET CONNECTION DEFAULT ;
See also the last example for the DISCONNECT statement, which illustrates the CONNECT, SET CONNECTION, and DISCONNECT statements in combination.