The ODBC interface provides functions that terminate statements, transactions, and connections, and free statement (hstmt), connection (hdbc), and environment (henv) handles.
To free resources associated with a statement handle, an application calls SQLFreeStmt. The SQLFreeStmt function has four options:
- SQL_CLOSE Closes the cursor, if one exists, and discards pending results. The application can use the statement handle again later.
- SQL_DROP Closes the cursor if one exists, discards pending results, and frees all resources associated with the statement handle.
- SQL_UNBIND Frees all return buffers bound by SQLBindCol for the statement handle.
- SQL_RESET_PARAMS Frees all parameter buffers requested by SQLBindParameter for the statement handle.
To cancel a statement that is executing asynchronously, an application:
- Calls SQLCancel. When and if the statement is actually canceled is driver- and data sourcedependent.
- Calls the function that was executing the statement asynchronously. If the statement is still executing, the function returns SQL_STILL_EXECUTING; if it was successfully canceled, the function returns SQL_ERROR and SQLSTATE S1008 (Operation canceled); if it completed normal execution, the function returns any valid return code, such as SQL_SUCCESS or SQL_ERROR.
- Calls SQLError if the function returned SQL_ERROR. If the driver successfully canceled the function, the SQLSTATE will be S1008 (Operation canceled).
An application calls SQLTransact to commit or roll back the current transaction.
To terminate a connection to a driver and data source, an application performs the following steps:
- 1. Calls SQLDisconnect to close the connection. The application can then use the handle to reconnect to the same data source or to a different data source.
- 2. Calls SQLFreeConnect to free the connection handle and free all resources associated with the handle.
- 3. Calls SQLFreeEnv to free the environment handle and free all resources associated with the handle.
Copyright © 1992-1997 Solid Information Technology Ltd All rights reserved.