The DISCONNECT statement disconnects one or all database connections.
DISCONNECT [connection_name | ALL | CURRENT]
When a connection is disconnected, all cursors opened for that connection are automatically closed.
To ensure a clean exit, an Embedded SQL program must issue a DISCONNECT ALL statement before it exits the main application.
EXEC SQL CONNECT TO caffe.pubs AS caffe1 USER sa;
EXEC SQL CONNECT TO latte.pubs AS latte1 USER sa;
EXEC SQL SET CONNECTION caffe1;
EXEC SQL SELECT name FROM sysobjects INTO :name;
EXEC SQL SET CONNECTION latte1;
EXEC SQL SELECT name FROM sysobjects INTO :name;
EXEC SQL DISCONNECT caffe1;
EXEC SQL DISCONNECT latte1;
// The first select takes place against the pubs //
// database on server "caffe." The second SELECT will //
// take place against the pubs database on server "latte." //
// In place of the two "disconnect" statements at the end, //
// you can also write: //
// EXEC SQL DISCONNECT ALL; //
CONNECT TO | SET CONNECTION |