Making a dormant connection as the current connection

If you use the SET CONNECTION statement without the DORMANT option, connection must represent a dormant connection. A dormant connection is a connection that is established but is not current.

The SET CONNECTION statement, with no DORMANT option, makes the specified dormant connection the current one. The connection that the application specifies must be dormant. The connection that is current when the statement executes becomes dormant.

The SET CONNECTION statement in the following example makes connection con1 the current connection and makes con2 a dormant connection:
CONNECT TO 'stores_demo' AS 'con1';
...
CONNECT TO 'demo' AS 'con2';
...
SET CONNECTION 'con1';

A dormant connection has a connection context associated with it. When an application makes a dormant connection current, it reestablishes that connection to a database environment and restores its connection context. (For more information on connection context, see the CONNECT statement statement on page CONNECT statement.) Reestablishing a connection is comparable to establishing the initial connection, except that it typically avoids authenticating the permissions for the user again, and it avoids reallocating resources associated with the initial connection. For example, the application does not need to reprepare any statements that have previously been prepared in the connection, nor does it need to redeclare any cursors.