Ends processing on the statement referenced by the statement handle.
SQLFreeStmt() is called after executing an SQL statement and processing the results.
SQLRETURN SQLFreeStmt (SQLHSTMT StatementHandle, /* hstmt */
SQLUSMALLINT Option); /* fOption */
Data type | Argument | Use | Description |
---|---|---|---|
SQLHSTMT | StatementHandle | input | Statement handle |
SQLUSMALLINT | Option | input | Option which specifies the manner of freeing the statement
handle. The option must have one of the following values:
|
SQLCloseCursor() can also be used to close a cursor.
This option has been replaced with a call to SQLFreeHandle() with the HandleType set to SQL_HANDLE_STMT. Although this version of CLI continues to support this option, begin using SQLFreeHandle() in your CLI programs so that they conform to the latest standards.
SQLFreeStmt() has no effect on LOB locators, call SQLExecDirect() with the FREE LOCATOR statement to free a locator.
Alternatively you may drop the statement handle and allocate a new one.
SQL_SUCCESS_WITH_INFO is not returned if Option is set to SQL_DROP, as there would be no statement handle to use when SQLGetDiagRec() or SQLGetDiagField() is called.
SQLSTATE | Description | Explanation |
---|---|---|
40003 08S01 | Communication link failure. | The communication link between the application and data source failed before the function completed. |
58004 | Unexpected system failure. | Unrecoverable system error. |
HY001 | Memory allocation failure. | DB2® CLI is unable to allocate memory required to support execution or completion of the function. It is likely that process-level memory has been exhausted for the application process. Consult the operating system configuration for information about process-level memory limitations. |
HY010 | Function sequence error. | The function was called while in a data-at-execute (SQLParamData(), SQLPutData()) operation. |
HY092 | Option type out of range. | The value specified for the argument Option was not SQL_CLOSE, SQL_DROP, SQL_UNBIND, or SQL_RESET_PARAMS. |
HY506 | Error closing a file. | Error encountered while trying to close a temporary file. |
None.
/* free the statement handle */
cliRC = SQLFreeStmt(hstmt, SQL_UNBIND);
rc = HandleInfoPrint(SQL_HANDLE_STMT, hstmt, cliRC, __LINE__, __FILE__);
if (rc != 0)
{
return 1;
}
/* free the statement handle */
cliRC = SQLFreeStmt(hstmt, SQL_RESET_PARAMS);
rc = HandleInfoPrint(SQL_HANDLE_STMT, hstmt, cliRC, __LINE__, __FILE__);
if (rc != 0)
{
return 1;
}
/* free the statement handle */
cliRC = SQLFreeStmt(hstmt, SQL_CLOSE);
rc = HandleInfoPrint(SQL_HANDLE_STMT, hstmt, cliRC, __LINE__, __FILE__);
if (rc != 0)
{
return 1;
}