⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 oracle_cancel.cpp

📁 SQLAPI C/C++ 连接Oracle 数据库!
💻 CPP
字号:
DWORD WINAPI Oracle_Cancel_Thread(void *_pCon){	SAConnection *pCon = (SAConnection *)_pCon;	SACommand cmd;	cmd.setConnection(pCon);	try	{		cmd.setCommandText("Update DEPT set DNAME=DNAME");		//cmd.setCommandText("sys.DBMS_PIPE.receive_message");		//cmd << SAPos("pipename") << "myPipe" << SAPos("timeout") << 10L;		cout << "Calling Execute!" << endl;		cmd.Execute();		cout << "Execute has been called!" << endl;	}    catch(SAException &x)    {		cout << "Oracle_Cancel_Thread: " << (const char*)x.ErrText() << endl;	}	return 0;}void Oracle_Cancel(){	SAConnection con2;	SAConnection con;	SACommand cmd2;	SACommand cmd;	cmd2.setConnection(&con2);	cmd.setConnection(&con);	try	{		con2.Connect(			"test", "scott", "tiger", SA_Oracle_Client);		//con.setOption("UseAPI") = "OCI7";		con.Connect(			"test", "scott", "tiger", SA_Oracle_Client);		// block		cmd2.setCommandText("Update DEPT set DNAME=DNAME");		cmd2.Execute();		DWORD ThreadId;		HANDLE hThread;		hThread = ::CreateThread(			NULL, 0,			Oracle_Cancel_Thread, &con,			0, &ThreadId);		WaitForSingleObject(hThread, 1000);		cout << "Calling Cancel!" << endl;		cmd.Open();		cmd.Cancel();		cout << "Cancel has been called!" << endl;		WaitForSingleObject(hThread, 2000);		cout << "Calling con2.Rollback()!" << endl;		con2.Rollback();		cout << "con2.Rollback() has been called!" << endl;		WaitForSingleObject(hThread, INFINITE);	}    catch(SAException &x)    {        // SAConnection::Rollback()        // can also throw an exception        // (if a network error for example),        // we will be ready        try        {            // on error rollback changes            con.Rollback();        }        catch(SAException &)        {        }        // print error message        cout << (const char*)x.ErrText() << endl;    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -