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.
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.
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: