CONNECT is an executable statement that can only be embedded in an application program. It cannot be dynamically prepared.
The primary AuthID for the application process must be authorized to connect to the specified location. The specific AuthID required is determined by that location, with the authorization check also performed by that location.
CONNECT [TO {location-name | host-variable}] [RESET]
location-name | Identifies a specific XDB Server system location. |
host-variable | Names a host variable name containing a location name. |
The following code excerpt connects the application process to the system location:
EXEC SQL CONNECT TO system;
To connect the application to a location named in the host variable nameloc, execute the following command:
EXEC SQL CONNECT TO :nameloc;
The XDB Server implements the CONNECT command identically to DB2, except that the XDB Server improves performance by leaving the old location open after connecting with the new location.
CONNECT RESET
The CONNECT RESET statement is equivalent to a CONNECT TO specifying the local XDB Server location.
Issuing this command is the only way to get back to an XDB Server location after connecting to a DB2 subsystem through the XDB Link.
CONNECT
The keyword CONNECT by itself returns information about the currently set XDB Server location. This information is placed in the SQLERRP field of the application SQLCA.
The initial server of an application process is the currently set XDB Server location. An explicit or implicit execution of a CONNECT [TO] statement can establish a different location. A CONNECT [TO] statement directed to the currently set location is treated like any other CONNECT [TO]. The CURRENT SQLID special register is not reinitialized when CONNECT [TO] is used to connect back to the currently set location.
Description
The CONNECT statement is the embedded SQL equivalent of the interactive SET LOCATION TO command. The CONNECT statement connects an application process to a designated location or a host-variable containing a location name. When the CONNECT statement is executed, the location name must be known to the local XDB Server running the application, or the location name must appear in the LOCATION column of the SYSIBM.SYSLOCATIONS catalog within the SYSTEM location.
Host variables must conform to the following requirements:
If the CONNECT statement execution is successful:
DOS
Windows NT
OS/2
For example, if running XDB Server for OS/2, the SQLERRP is XDB0400O.