f90SQLFreeStmt (SQLFreeStmt)

 

Conformance

Version Introduced: ODBC 1.0

Standards Compliance: ISO 92

 

Summary

f90SQLFreeStmt stops processing associated with a specific statement, closes any open cursors associated with the statement, discards pending results, or, optionally, frees all resources associated with the statement handle.

 

Syntax

f90SQLFreeStmt (StatementHandle, Option, iRet)

 

integer(SQLHSTMT_KIND),intent(in):: StatementHandle
integer(SQLUSMALLINT_KIND),intent(in):: Option
integer(SQLRETURN_KIND),intent(out):: iRet

 

Arguments

StatementHandle [Input]

Statement handle

Option [Input]

One of the following options:

iRet [Output]

SQL_SUCCESS, SQL_SUCCESS_WITH_INFO, SQL_ERROR, or SQL_INVALID_HANDLE.

Diagnostics

When f90SQLFreeStmt returns SQL_ERROR or SQL_SUCCESS_WITH_INFO, an associated SQLSTATE value may be obtained by calling f90SQLGetDiagRec with a HandleType of SQL_HANDLE_STMT and a Handle of StatementHandle. The following table lists the SQLSTATE values commonly returned by f90SQLFreeStmt and explains each one in the context of this function; the notation "(DM)" precedes the descriptions of SQLSTATEs returned by the Driver Manager. The return code associated with each SQLSTATE value is SQL_ERROR, unless noted otherwise.

SQLSTATE Error Description
01000 General warning Driver-specific informational message.

(Function returns SQL_SUCCESS_WITH_INFO.)

HY000 General error An error occurred for which there was no specific SQLSTATE and for which no implementation-specific SQLSTATE was defined. The error message returned by f90SQLGetDiagRec in the MessageText buffer describes the error and its cause.
HY001 Memory allocation error The driver was unable to allocate memory required to support execution or completion of the function.
HY010 Function sequence error (DM) An asynchronously executing function was called for the StatementHandle and was still executing when this function was called.

(DM) f90SQLExecute, f90SQLExecDirect, f90SQLBulkOperations, or f90SQLSetPos was called for the StatementHandle and returned SQL_NEED_DATA. This function was called before data was sent for all data-at-execution parameters or columns.

HY013 Memory management error The function call could not be processed because the underlying memory objects could not be accessed, possibly because of low memory conditions.
HY092 Option type out of range (DM) The value specified for the argument Option was not:

SQL_CLOSE
SQL_DROP
SQL_UNBIND
SQL_RESET_PARAMS

HYT01 Connection timeout expired The connection timeout period expired before the data source responded to the request. The connection timeout period is set through f90SQLSetConnectAttr, SQL_ATTR_CONNECTION_TIMEOUT.
IM001 Driver does not support this function (DM) The driver associated with the StatementHandle does not support the function.

 

Comments

Calling f90SQLFreeStmt with the SQL_CLOSE option is equivalent to calling f90SQLCloseCursor, with the exception that f90SQLFreeStmt with SQL_CLOSE has no effect on the application if no cursor is open on the statement. If no cursor is open, a call to f90SQLCloseCursor returns SQLSTATE 24000 (Invalid cursor state).

An application should not use a statement handle after it has been freed; the Driver Manager does not check the validity of a handle in a function call.

 

Code Example

See f90SQLBrowseConnect and f90SQLConnect and Chapters 4 and 5.

 

Related Subroutines

For information about See
Allocating a handle f90SQLAllocHandle
Canceling statement processing f90SQLCancel
Closing a cursor f90SQLCloseCursor
Freeing a handle f90SQLFreeHandle
Setting a cursor name f90SQLSetCursorName