contents.gifindex.gifprev1.gifnext1.gif

2.4 CONNECT Statement

The syntax and semantics of the CONNECT statement are given here for clarity.

CONNECT TO server-name [AS connection-name] [USER userid USING passwd]

1. server-name, connection-name, and userid are alphanumeric literals or host-variables defined in an ESQL DECLARE section of Working-Storage. Note that you must place a colon (":") before the host-variable in the SQL statement.

2. passwd is a variable length character string (varchar, in DB2). Note that leading and trailing spaces are not stripped.

The CONNECTION statement attempts to establish a connection with server-name as user userid. The "AS connection-name" clause assigns the specified name to the connection. This is especially desirable when you want to establish multiple connections.

Example:

CONNECT TO big-data AS con1 USER :uid USING :pwd

Note that "big-data" and "con1" are alphanumeric literals. "uid" and "pwd" are host-variables. Host-variables must be preceded by a colon (":"). See the sample programs for a working example.