8. SQL Statements : CONNECT : Syntax
 
Share this page                  
Syntax
The CONNECT statement has the following format:
EXEC SQL CONNECT dbname
              [AS connection_name]
              [SESSION session_number]
              [IDENTIFIED BY username]
              [DBMS_PASSWORD = dbms_password]
              [OPTIONS = flag {, flag}]
              [WITH HIGHDXID = value, LOWDXID = value]
dbname
Specifies the database to which the session connects. Dbname can be a quoted or unquoted string literal or a host string variable. If the name includes any name extensions (such as a system or node name), string literals must be quoted.
connection_name
Specifies an alphanumeric identifier to be associated with the session. The connection name must be a string of up to 128 characters that identifies the session. If the as connection_name clause and the session clause are omitted, the default connection name is the specified database name.
Connection_name must be specified using a quoted string literal or a host language variable.
session_number
Specifies a numeric identifier to be associated with the session. The session number must be a positive integer literal or variable, and must be unique among existing session numbers in the application.
username
Specifies the user identifier under which this session runs. Username can be specified using a quoted or unquoted string literal or string variable.
dbms_password
Specifies the valid password either as string constant or a string program variable. This parameter allows the application to specify the password at connection time if required.
flag
Specifies runtime options for the connection. Valid flags are those accepted by the sql command. Flags specific to the Terminal Monitor are not valid. For more information about these flags, see the Command Reference Guide.
The maximum number of flags is 12.
Common flags are:
-uusername
Specifies the effective user for the session.
-Ggroupid
Specifies a group identifier.
-Rroleid
Specifies a role identifier for the session. If the role ID has a password, use the format:
'-Rroleid/password '
The flags can be specified using quoted or unquoted character string literals or string variables.
value
Highdxid specifies the high-order 4 bytes of a distributed transaction ID. Lowdxid specifies the low-order 4 bytes of a distributed transaction ID. These options are used for two phase commit of distributed transactions. For details, see the chapter “Working with Transactions and Handling Errors.”