DECLARE CONNECTION HANDLE SET (Declare connection handle to be used)
Function
In an environment that uses the multi-connection facility, DECLARE CONNECTION HANDLE SET declares the connection handle that is used by SQL statements in a UAP or by the SQL Communications Area.
Format
DECLARE CONNECTION HANDLE SET :PDCNCTHDL-type-variable
Operands
Specifies the embedded variable that was declared as a PDCNCTHDL-type variable.
Common rules
- The scope of the connection handle specified in DECLARE CONNECTION HANDLE SET depends on the location in the source program where the connection handle appears. The variable for the connection handle specified in a DECLARE CONNECTION HANDLE SET is effective on all SQL statements until another DECLARE CONNECTION HANDLE SET or DECLARE CONNECTION HANDLE UNSET appears.
- The connection handle to be used can be declared as many times as necessary in the same UAP.
Notes
- For the C language, any SQL statement that was issued before DECLARE CONNECTION HANDLE SET was coded is processed under the assumption that the SQL statement was issued in the single-connection environment.
For the COBOL language, UAPs using the multi-connection facility cannot code an SQL statement before DECLARE CONNECTION HANDLE SET is coded.
- What is declared in a DECLARE CONNECTION HANDLE SET statement is the name of a variable for a connection handle; it is not the value itself.
- Before referencing the SQL communication area storing the results of execution of an SQL statement using the multi-connection facility, DECLARE CONNECTION HANDLE SET must be executed using the module.
Example
Declare a connection handle whose PDCNCTHDL-type variable is hCnct:
- C language
EXEC SQL BEGIN DECLARE SECTION;
PDCNCTHDL CnctHdl;
EXEC SQL END DECLARE SECTION;
EXEC SQL DECLARE CONNECTION HANDLE SET :CnctHdl;
- COBOL language
EXEC SQL BEGIN DECLARE SECTION END-EXEC
01 CNCTHDL SQL TYPE IS PDCNCTHDL.
EXEC SQL END DECLARE SECTION END-EXEC
EXEC SQL DECLARE CONNECTION HANDLE SET :CNCTHDL END-EXEC