Oracle® Objects for OLE C++ Class Library Developer's Guide 10g Release 2 (10.2) B14308-01 |
|
Applies To
Description
This method is called to cancel a non-blocking operation that is underway on the OSqlStmt object. Valid only if the OSqlStmt object has been created with OSQLSTMT_NONBLK option.
Usage
oresult Cancel(void) const
Arguments
none |
The application can cancel a long running asynchronous operation by calling the Cancel method on the OSqlStmt object. The Cancel method will cancel the execution that is in progress.
Return Values
An oresult indicating whether the operation succeeded (OSUCCESS) or not (OFAILURE).
Errors are thrown as exceptions.
Example
This example uses try and catch blocks.
//try block try { long ret; OStartup(OSTARTUP_MULTITHREADED); osess.Open(); odb.Open(osess, "ExampleDB", "scott", "tiger"); if ( ! odb.IsOpen() ) { cout << "Database not opened: " << odb.GetErrorText() << endl; odb.Close(); return(-1); } // To cancel an asynchronous execution OSqlStmt osqlstmt(odb, "update junk set ichar='CANCEL' where iint 100" ,OSQLSTMT_NONBLK); if ( ret != OSQL_SUCCESS ) cout << "Error " << osqlstmt.GetErrorText() << endl; ret = osqlstmt.NonBlockingState(); if ( ret == OSQL_STILL_EXECUTING ) { ret = osqlstmt.Cancel(); if ( ret != OSQL_SUCCESS ) cout << "Error " << osqlstmt.GetErrorText() << endl; else cout << "Cancel of non-block execution succesful" << endl; } } //catch block catch(OException oerr) { cout << "Exception while executing non-blocking mode : " << oerr.GetErrorText() << endl; retVal = -1; }
Additional examples can be found in ORACLE_BASE\ORACLE_HOME\oo4o\cpp. See About Sample Code and Applications.