The CONNECT TO statement connects to a specific database with the supplied username and password.
CONNECT TO {[server_name.]database_name} [AS connection_name] USER [login[.password] | $integrated]
The options can include character literals or host variables. If you use only one connection, you do not need to supply a name for the connection. When you use more than one connection, you must specify a name for each connection.
Connection names are global within a process. Named connections are shared by separately compiled programs linked into a single executable module. Named connections are also shared by a program and dynamic-link libraries that execute in a single process.
All database transactions after a CONNECT TO statement that do not involve a browse cursor work through the most recently declared, current connection. To use a different connection, you must use the SET CONNECTION statement.
EXEC SQL CONNECT TO :svr USER :usr;
Or
EXEC SQL CONNECT TO "gizmo.pubs" USER "sa";
Or
EXEC SQL CONNECT TO gizmo.pubs USER sa;
DISCONNECT |