SQLFreeStmt - Free (or reset) a statement handle

 

SQLFreeStmt() ends processing on the statement that is referenced by the statement handle.

You can use this function to complete the following tasks:

SQLFreeStmt() is called after executing an SQL statement and processing the results.

 

Syntax

SQLRETURN SQLFreeStmt (SQLHSTMT       hstmt,
                       SQLSMALLINT    fOption);

 

Function arguments

Table 1. SQLFreeStmt arguments
Data type Argument Use Description
SQLHSTMT hstmt Input Statement handle
SQLSMALLINT fOption Input Option specifying the manner of freeing the statement handle. The option must have one of the following values:

  • SQL_CLOSE

  • SQL_DROP

  • SQL_UNBIND

  • SQL_RESET_PARAMS

 

Usage

SQLFreeStmt() can be called with the following options:

To reuse a statement handle to run a different statement and if the previous statement:

Alternatively you can drop the statement handle and allocate a new one.

 

Return codes

SQL_SUCCESS_WITH_INFO is not returned if fOption is set to SQL_DROP, because there is no statement handle to use when SQLError() is called.

 

Diagnostics

Table 2. SQLFreeStmt SQLSTATEs
SQLSTATE Description Explanation
40003 * Statement completion unknown The communication link between the CLI and the data source fails before the function completes processing.
58004 System error Unrecoverable system error.
HY001 Memory allocation failure The driver is unable to allocate memory required to support the processing or completion of the function.
HY009 Argument value that is not valid The value specified for the argument fOption is not SQL_CLOSE, SQL_DROP, SQL_UNBIND, or SQL_RESET_PARAMS.
HY021 Internal descriptor that is not valid The internal descriptor cannot be addressed or allocated, or it contains a value that is not valid.

 

Example

Refer to the example in SQLFetch - Fetch next row.

 

References

 

Parent topic:

DB2 UDB CLI functions