Causes the specified existing connection to become the current connection.
set connection {connection_name | DEFAULT} end-exec
The name of an existing connection that you want to become the current connection.
Specifies that the unnamed default connection is to become the current connection.
EXEC SQL BEGIN DECLARE SECTION END-EXEC.
01 MYID PIC X(33).
EXEC SQL END DECLARE SECTION END-EXEC.
...
EXEC SQL CONNECT "user1" AT connect1 USING "SERVER1" END-EXEC.
EXEC SQL CONNECT "user2" AT connect2 USING "SERVER2" END-EXEC.
* The next statement executes on connect2, because that was the
* last connection made.
EXEC SQL SELECT user_name() INTO :MYID END-EXEC.
DISPLAY "The user connected to SERVER2 is: ",MYID.
* Explicitly set the connection to now use to connect1.
EXEC SQL SET CONNECTION connect1 END-EXEC.
* The following statement will execute on connect1.
EXEC SQL SELECT user_name() INTO :MYID END-EXEC.
DISPLAY "The user connected to SERVER1 is: ",MYID.
The set connection statement specifies the current connection for all subsequent SQL statements, except those preceded by the exec sql clause at.
A set connection statement remains in effect until you choose a different current connection by using the set connection statement again.
at connection_name, connect