SQL$HELP72.HLB  —  RELEASE
    Releases all resources used by a prepared dynamic SQL statement
    and prevents the prepared statement from executing again.

    The RELEASE statement is a dynamic SQL statement. Dynamic SQL
    lets programs accept or generate SQL statements at run time,
    in contrast to SQL statements that are part of the source code
    for precompiled programs or SQL module language procedures.
    Unlike precompiled SQL or SQL module language statements, such
    dynamically executed SQL statements are not necessarily part of a
    program's source code, but can be generated while the program is
    running. Dynamic SQL is useful when you cannot predict the type
    of SQL statement your program will need to process.

1  –  Environment

    You can use the RELEASE statement:

    o  Embedded in host language programs to be precompiled

    o  As part of a procedure in an SQL module

2  –  Format

  (B)0RELEASE qw> <statement-name> qqqqqqqqwq>  
           m> <statement-id-parameter> j    

3  –  Arguments

3.1  –  statement-name

    Specifies the name of a prepared statement or a statement name
    assigned in a PREPARE statement.

    A single set of dynamic SQL statements (PREPARE, DESCRIBE,
    EXECUTE, dynamic DECLARE CURSOR) can handle any number of
    dynamically executed statements.

    You can supply either a parameter or a compile-time statement
    name to identify the statement to be executed. Specifying a
    parameter lets SQL supply identifiers to programs at run time.
    Use an integer parameter to contain the statement identifier
    returned by SQL or a character string parameter to contain
    the name of the statement that you pass to SQL. If you use
    parameters, statements that refer to the prepared statement
    (DESCRIBE, EXECUTE, DECLARE CURSOR) must also use those
    parameters instead of the explicit statement name.

3.2  –  statement-id-parameter

    Specifies the name of a prepared statement or a statement name
    assigned in a PREPARE statement.

    A single set of dynamic SQL statements (PREPARE, DESCRIBE,
    EXECUTE, dynamic DECLARE CURSOR) can handle any number of
    dynamically executed statements.

    You can supply either a parameter or a compile-time statement
    name to identify the statement to be executed. Specifying a
    parameter lets SQL supply identifiers to programs at run time.
    Use an integer parameter to contain the statement identifier
    returned by SQL or a character string parameter to contain
    the name of the statement that you pass to SQL. If you use
    parameters, statements that refer to the prepared statement
    (DESCRIBE, EXECUTE, DECLARE CURSOR) must also use those
    parameters instead of the explicit statement name.

4  –  Example

    Example 1: Using the RELEASE statement

    The following fragment from a COBOL program shows using a RELEASE
    statement to release resources from a prepared SELECT statement:

            .
            .
            .

    FETCHES.
            DISPLAY "Here's the row we stored:"

            EXEC SQL PREPARE STMT FROM
            'SELECT * FROM EMPLOYEES WHERE EMPLOYEE_ID = "99999"'
            END-EXEC
            EXEC SQL DECLARE C CURSOR FOR STMT END-EXEC

            EXEC SQL OPEN C END-EXEC
            .
            .
            .

            EXEC SQL FETCH C INTO
                    :EMP_ID:EMP_ID_IND,
                    :LNAME:LNAME_IND,
                    :FNAME:FNAME_IND,
                    :MID_INIT:MID_INIT_IND,
                    :ADDR_1:ADDR_1_IND,
                    :ADDR_2:ADDR_2_IND,
                    :CITY:CITY_IND,
                    :STATE:STATE_IND,
                    :P_CODE:P_CODE_IND,
                    :SEX:SEX_IND,
                    :BDATE:BDATE_IND,
                    :S_CODE:S_CODE_IND
            END-EXEC

            DISPLAY EMP_ID," ",
                    FNAME," ",
                    MID_INIT," ",
                    LNAME," ",
                    ADDR_1," ",
                    ADDR_2," ",
                    CITY," ",
                    STATE," ",
                    P_CODE," ",
                    SEX," ",
                    BDATE," ",
                    S_CODE.

            PERFORM CHECK
            EXEC SQL CLOSE C END-EXEC.
            PERFORM CHECK.
            EXEC SQL RELEASE STMT END-EXEC.
            PERFORM CHECK.
            .
            .
            .
Close Help