Hitachi

Hitachi Advanced Database Application Development Guide


18.2.5 Canceling SQL processing that is executing

You can use a_rdb_SQLCancel() to cancel SQL processing that is executing. The following SQL statements (CLI functions) can be canceled:

You must execute a_rdb_SQLCancel() in a separate thread from the thread being used for the SQL processing. The following shows an example of canceling SQL processing.

SQL execution thread
rtnc = a_rdb_SQLAllocStmt(hCnct, &hStmt, NULL) ;
/* Execute the DELETE statement */
rtnc = a_rdb_SQLExecDirect(hCnct,
                           hStmt,
                           "DELETE FROM TABLE1",
                           NULL) ;
/* Check whether SQL processing was canceled */
if ( rtnc == -955 )
{
  /* Processing after cancellation */
}
else ;
Example of canceling an SQL statement (executing in a separate thread)
/* Execute the SQL cancel function */
rtnc = a_rdb_SQLCancel(hCnct, NULL) ;
                  /* Specify the connection handle being used for the   */
                  /* SQL processing that is to be canceled */

When cancellation of SQL processing is successful, the SQL processing is canceled, the transaction is rolled back, and SQLCODE is returned.

For details about a_rdb_SQLCancel(), see 19.3.1 a_rdb_SQLCancel() (cancel SQL processing).

Note that normal termination of a_rdb_SQLCancel() does not mean that the cancellation processing was successful because the cancellation processing is performed asynchronously with a_rdb_SQLCancel().