FREE CONNECTION HANDLE (Release connection handle)

Function

FREE CONNECTION HANDLE releases a connection handle that was allocated by ALLOCATE CONNECTION HANDLE.

Format

FREE CONNECTION HANDLE :PDCNCTHDL-type-variable
                         :return-code-receiving-variable

Operands

Specifies the PDCNCTHDL-type variable that was specified in ALLOCATE CONNECTION HANDLE.

Specifies the return code receiving variable that was specified in ALLOCATE CONNECTION HANDLE.

The following values are returned to the return code receiving variable:

C language
Normal allocation:
p_rdb_RC_NORM
Invalid connection handle value:
p_rdb_RC_ERRPARM
Connection handle being used:
p_rdb_RC_SIMERR
These values are defined in the pdberrno.h file.
COBOL language
Normal allocation:
P_RDB_RC_NORM
Invalid connection handle value:
P_RDB_RC_ERRPARM
Connection handle being used:
P_RDB_RC_SIMERR
These values are defined in the SQLCAMTH.CBL file.

Common rules

  1. FREE CONNECTION HANDLE should be issued after a DISCONNECT statement.
  2. The embedded variables to be used must have been declared in the embedded SQL declare section.
  3. If release of a connection handle fails, the system sets the error code in the return code receiving variable.

Note

Connection handles that have been reserved are not released when a DISCONNECT statement is issued. To release a connection handle, a FREE CONNECTION HANDLE statement must be issued.

Example

Release the connection handle that was allocated in the example shown in the section on ALLOCATE CONNECTION HANDLE:

C language

EXEC SQL BEGIN DECLARE SECTION;
 PDCNCTHDL   CnctHdl;
 long        FrchdlRtn;
EXEC SQL END DECLARE SECTION;
EXEC SQL FREE CONNECTION HANDLE :CnctHdl,
                               :FrchdlRtn;

COBOL language

DATA DIVISION.
WORKING-STORAGE SECTION.
 EXEC SQL
   BEGIN DECLARE SECTION
 END-EXEC.
01 CNCTHDL     SQL TYPE IS PDCNCTHDL.
01 FRCHDLRTN   PIC S9(9) COMP.
 EXEC SQL
   END DECLARE SECTION
 END-EXEC.
       :
PROCEDURE DIVISION.
       :
 EXEC SQL
   FREE CONNECTION HANDLE :CNCTHDL,
                          :FRCHDLRTN;
 END-EXEC.