📄 cursor.cpp
字号:
switch ( ct_send(m_Cmd) ) { case CS_SUCCEED: break; case CS_FAIL: m_HasFailed = true; throw CDB_ClientEx(eDB_Error, 122042, "CTL_CursorCmd::Delete", "ct_send failed"); case CS_CANCELED: throw CDB_ClientEx(eDB_Error, 122043, "CTL_CursorCmd::Delete", "command was canceled"); case CS_BUSY: case CS_PENDING: throw CDB_ClientEx(eDB_Error, 122044, "CTL_CursorCmd::Delete", "connection has another request pending"); } // process the results for (;;) { CS_INT res_type; switch ( ct_results(m_Cmd, &res_type) ) { case CS_SUCCEED: break; case CS_END_RESULTS: return true; case CS_FAIL: m_HasFailed = true; throw CDB_ClientEx(eDB_Error, 122045, "CTL_CursorCmd::Delete", "ct_result failed"); case CS_CANCELED: throw CDB_ClientEx(eDB_Error, 122046, "CTL_CursorCmd::Delete", "your command has been canceled"); case CS_BUSY: throw CDB_ClientEx(eDB_Error, 122047, "CTL_CursorCmd::Delete", "connection has another request pending"); default: throw CDB_ClientEx(eDB_Error, 122048, "CTL_CursorCmd::Delete", "your request is pending"); } if(m_Connect->m_ResProc) { I_Result* res= 0; switch (res_type) { case CS_ROW_RESULT: res = new CTL_RowResult(m_Cmd); break; case CS_PARAM_RESULT: res = new CTL_ParamResult(m_Cmd); break; case CS_COMPUTE_RESULT: res = new CTL_ComputeResult(m_Cmd); break; case CS_STATUS_RESULT: res = new CTL_StatusResult(m_Cmd); break; } if(res) { CDB_Result* dbres= Create_Result(*res); m_Connect->m_ResProc->ProcessResult(*dbres); delete dbres; delete res; continue; } } switch ( res_type ) { case CS_CMD_SUCCEED: case CS_CMD_DONE: // done with this command continue; case CS_CMD_FAIL: // the command has failed m_HasFailed = true; while(ct_results(m_Cmd, &res_type) == CS_SUCCEED); throw CDB_ClientEx(eDB_Warning, 122049, "CTL_CursorCmd::Delete", "The server encountered an error while " "executing a command"); default: continue; } }}int CTL_CursorCmd::RowCount() const{ return m_RowCount;}bool CTL_CursorCmd::Close(){ if ( !m_IsOpen ) { return false; } if (m_Res) { delete m_Res; m_Res = 0; } switch ( ct_cursor(m_Cmd, CS_CURSOR_CLOSE, 0, CS_UNUSED, 0, CS_UNUSED, CS_UNUSED) ) { case CS_SUCCEED: break; case CS_FAIL: m_HasFailed = true; throw CDB_ClientEx(eDB_Fatal, 122020, "CTL_CursorCmd::Close", "ct_cursor(close) failed"); case CS_BUSY: throw CDB_ClientEx(eDB_Error, 122021, "CTL_CursorCmd::Close", "the connection is busy"); } // send this command switch ( ct_send(m_Cmd) ) { case CS_SUCCEED: break; case CS_FAIL: m_HasFailed = true; throw CDB_ClientEx(eDB_Error, 122022, "CTL_CursorCmd::Close", "ct_send failed"); case CS_CANCELED: throw CDB_ClientEx(eDB_Error, 122023, "CTL_CursorCmd::Close", "command was canceled"); case CS_BUSY: case CS_PENDING: throw CDB_ClientEx(eDB_Error, 122024, "CTL_CursorCmd::Close", "connection has another request pending"); } m_IsOpen = false; CS_INT res_type; for (;;) { switch ( ct_results(m_Cmd, &res_type) ) { case CS_SUCCEED: break; case CS_END_RESULTS: return true; case CS_FAIL: m_HasFailed = true; throw CDB_ClientEx(eDB_Error, 122025, "CTL_CursorCmd::Close", "ct_result failed"); case CS_CANCELED: throw CDB_ClientEx(eDB_Error, 122026, "CTL_CursorCmd::Close", "your command has been canceled"); case CS_BUSY: throw CDB_ClientEx(eDB_Error, 122027, "CTL_CursorCmd::Close", "connection has another request pending"); default: throw CDB_ClientEx(eDB_Error, 122028, "CTL_CursorCmd::Close", "your request is pending"); } if(m_Connect->m_ResProc) { I_Result* res= 0; switch (res_type) { case CS_ROW_RESULT: res = new CTL_RowResult(m_Cmd); break; case CS_PARAM_RESULT: res = new CTL_ParamResult(m_Cmd); break; case CS_COMPUTE_RESULT: res = new CTL_ComputeResult(m_Cmd); break; case CS_STATUS_RESULT: res = new CTL_StatusResult(m_Cmd); break; } if(res) { CDB_Result* dbres= Create_Result(*res); m_Connect->m_ResProc->ProcessResult(*dbres); delete dbres; delete res; continue; } } switch ( res_type ) { case CS_CMD_SUCCEED: case CS_CMD_DONE: // done with this command continue; case CS_CMD_FAIL: // the command has failed m_HasFailed = true; while (ct_results(m_Cmd, &res_type) == CS_SUCCEED) { continue; } throw CDB_ClientEx(eDB_Warning, 122029, "CTL_CursorCmd::Close", "The server encountered an error while " "executing a command"); } }}void CTL_CursorCmd::Release(){ m_BR = 0; if ( m_IsOpen ) { Close(); m_IsOpen = false; } m_Connect->DropCmd(*this); delete this;}CTL_CursorCmd::~CTL_CursorCmd(){ if ( m_BR ) { *m_BR = 0; } if ( m_IsOpen ) { Close(); } if ( m_Used ) { // deallocate the cursor switch ( ct_cursor(m_Cmd, CS_CURSOR_DEALLOC, 0, CS_UNUSED, 0, CS_UNUSED, CS_UNUSED) ) { case CS_SUCCEED: break; case CS_FAIL: // m_HasFailed = true; //throw CDB_ClientEx(eDB_Fatal, 122050, "::~CTL_CursorCmd", // "ct_cursor(dealloc) failed"); case CS_BUSY: //throw CDB_ClientEx(eDB_Error, 122051, "::~CTL_CursorCmd", // "the connection is busy"); ct_cmd_drop(m_Cmd); return; } // send this command switch ( ct_send(m_Cmd) ) { case CS_SUCCEED: break; case CS_FAIL: // m_HasFailed = true; // throw CDB_ClientEx(eDB_Error, 122052, "::~CTL_CursorCmd", // "ct_send failed"); case CS_CANCELED: // throw CDB_ClientEx(eDB_Error, 122053, "::~CTL_CursorCmd", // "command was canceled"); case CS_BUSY: case CS_PENDING: // throw CDB_ClientEx(eDB_Error, 122054, "::~CTL_CursorCmd", // "connection has another request pending"); ct_cmd_drop(m_Cmd); return; } // process the results for (bool need_cont = true; need_cont; ) { CS_INT res_type; switch ( ct_results(m_Cmd, &res_type) ) { case CS_SUCCEED: break; case CS_END_RESULTS: need_cont = false; continue; case CS_FAIL: // m_HasFailed = true; //throw CDB_ClientEx(eDB_Error, 122055, "::~CTL_CursorCmd", // "ct_result failed"); case CS_CANCELED: // throw CDB_ClientEx(eDB_Error, 122056, "::~CTL_CursorCmd", // "your command has been canceled"); case CS_BUSY: // throw CDB_ClientEx(eDB_Error, 122057, "::~CTL_CursorCmd", // "connection has another request pending"); default: //throw CDB_ClientEx(eDB_Error, 122058, "::~CTL_CursorCmd", // "your request is pending"); need_cont = false; continue; } if(m_Connect->m_ResProc) { I_Result* res= 0; switch (res_type) { case CS_ROW_RESULT: res = new CTL_RowResult(m_Cmd); break; case CS_PARAM_RESULT: res = new CTL_ParamResult(m_Cmd); break; case CS_COMPUTE_RESULT: res = new CTL_ComputeResult(m_Cmd); break; case CS_STATUS_RESULT: res = new CTL_StatusResult(m_Cmd); break; } if(res) { CDB_Result* dbres= Create_Result(*res); m_Connect->m_ResProc->ProcessResult(*dbres); delete dbres; delete res; continue; } } switch ( res_type ) { case CS_CMD_SUCCEED: case CS_CMD_DONE: // done with this command continue; case CS_CMD_FAIL: // the command has failed // m_HasFailed = true; while (ct_results(m_Cmd, &res_type) == CS_SUCCEED); // throw CDB_ClientEx(eDB_Warning, 122059, "::~CTL_CursorCmd", // "The server encountered an error while " // "executing a command"); need_cont = false; default: continue; } } }#if 0 if (ct_cmd_drop(m_Cmd) != CS_SUCCEED) { // throw CDB_ClientEx(eDB_Fatal, 122060, "::~CTL_CursorCmd", // "ct_cmd_drop failed"); }#else ct_cmd_drop(m_Cmd);#endif}bool CTL_CursorCmd::x_AssignParams(bool declare_only){ CS_DATAFMT param_fmt; memset(¶m_fmt, 0, sizeof(param_fmt)); param_fmt.namelen = CS_NULLTERM; param_fmt.status = CS_INPUTVALUE; for (unsigned int i = 0; i < m_Params.NofParams(); i++) { if(m_Params.GetParamStatus(i) == 0) continue; CDB_Object& param = *m_Params.GetParam(i); const string& param_name = m_Params.GetParamName(i); CS_SMALLINT indicator = (!declare_only && param.IsNULL()) ? -1 : 0; if ( !g_CTLIB_AssignCmdParam(m_Cmd, param, param_name, param_fmt, indicator, declare_only) ) { return false; } } return true;}END_NCBI_SCOPE/* * =========================================================================== * $Log: cursor.cpp,v $ * Revision 1000.1 2004/06/01 19:19:41 gouriano * PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.9 * * Revision 1.9 2004/05/17 21:12:03 gorelenk * Added include of PCH ncbi_pch.hpp * * Revision 1.8 2003/06/05 16:00:31 soussov * adds code for DumpResults and for the dumped results processing * * Revision 1.7 2003/05/16 20:24:24 soussov * adds code to skip parameters if it was not set * * Revision 1.6 2002/09/16 16:34:16 soussov * add try catch when canceling in Release method * * Revision 1.5 2002/05/16 21:35:22 soussov * fixes the memory leak in text/image processing * * Revision 1.4 2002/03/26 15:34:38 soussov * new image/text operations added * * Revision 1.3 2001/11/06 17:59:55 lavr * Formatted uniformly as the rest of the library * * Revision 1.2 2001/09/25 16:29:57 soussov * fixed typo in CTL_CursorCmd::x_AssignParams * * Revision 1.1 2001/09/21 23:40:02 vakatov * ----- Initial (draft) revision. ----- * This is a major revamp (by Denis Vakatov, with help from Vladimir Soussov) * of the DBAPI "driver" libs originally written by Vladimir Soussov. * The revamp involved massive code shuffling and grooming, numerous local * API redesigns, adding comments and incorporating DBAPI to the C++ Toolkit. * * =========================================================================== */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -