Use the set connection statement to change the current connection. The statement’s syntax is:
exec sql set connection {connection_name | default}
where “default” is the unnamed connection, if any.
The following example changes the current connection:
exec sql connect "ME" at connect1 using "SERVER1" end-exec
exec sql connect "ME" at connect2 using "SERVER2" end-exec
exec sql set connection connect1 end-exec
exec-sql select user_id()into :MYID end-exec