8. OpenSQL Statements : CONNECT : Description
 
Share this page                  
Description
The embedded SQL CONNECT statement connects an application to a database, similar to the operating-system-level SQL and ISQL commands. The CONNECT statement must precede all statements that access the database. The CONNECT statement cannot be issued in a dynamic OpenSQL statement.
Use the SESSION clause if your application includes multiple open sessions (see page Multiple Session Connections). The SESSION clause uniquely identifies each session, by associating each session with the specified session_identifier. The session identifier must be a positive integer.
Multiple-session applications require the SESSION clause on each CONNECT statement including the first. If this clause is not present on the first connect in the application, OpenSQL assumes that the application does not use multiple open sessions, and subsequent attempts to open other sessions generate an error.
To switch from one existing session to another existing session, use the SET_SQL statement. The CONNECT statement with the SESSION clause is used only to establish new sessions. You can, however, open more than one session with the same database.
The identified by clause allows the session to run as the specified user, like the -u flag of the SQL command. To determine whether your Enterprise Access product supports the -u flag (and, therefore, the identified by clause), see your Enterprise Access product guide.
The OPTIONS clause allows up to twelve flags to be specified that control session behavior. For details about these flags, see the description of the SQL command in the Command Reference Guide. Not all flags are supported by all Enterprise Access products.
The WITH clause (see page Enterprise Access and EDBC With Clause) enables Enterprise Access product‑specific connection parameters to be specified. To determine the options supported by a specific Enterprise Access product, see your Enterprise Access product guide.