diff options
Diffstat (limited to 'lib/LuaOCCI.cc')
-rw-r--r-- | lib/LuaOCCI.cc | 196 |
1 files changed, 181 insertions, 15 deletions
diff --git a/lib/LuaOCCI.cc b/lib/LuaOCCI.cc index 85b2a42..8c02e9f 100644 --- a/lib/LuaOCCI.cc +++ b/lib/LuaOCCI.cc @@ -37,7 +37,10 @@ T * lua_recast(Lua * L, int n = 1) { ConnectionPool support. */ enum EncapOCCI_Environment_methods_t { - ENVIRONMENT_CREATECONNECTION = 0, + ENVIRONMENT_SETEXCEPTIONS = 0, + ENVIRONMENT_GETERRORMSG, + ENVIRONMENT_GETERRORCODE, + ENVIRONMENT_CREATECONNECTION, ENVIRONMENT_GETCACHEMAXSIZE, ENVIRONMENT_GETCACHEOPTSIZE, ENVIRONMENT_GETCURRENTHEAPSIZE, @@ -52,6 +55,9 @@ enum EncapOCCI_Environment_functions_t { }; struct lua_functypes_t EncapOCCI_Environment_methods[] = { + { ENVIRONMENT_SETEXCEPTIONS, "setExceptions", 1, 1, { BLUA_BOOLEAN } }, + { ENVIRONMENT_GETERRORMSG, "getErrorMsg", 0, 0, { } }, + { ENVIRONMENT_GETERRORCODE, "getErrorCode", 0, 0, { } }, { ENVIRONMENT_CREATECONNECTION, "createConnection", 2, 3, { BLUA_STRING, BLUA_STRING, BLUA_STRING } }, { ENVIRONMENT_GETCACHEMAXSIZE, "getCacheMaxSize", 0, 0, { } }, { ENVIRONMENT_GETCACHEOPTSIZE, "getCacheOptSize", 0, 0, { } }, @@ -70,7 +76,15 @@ struct lua_functypes_t EncapOCCI_Environment_functions[] = { class sLua_EncapOCCI_Environment : public Base { public: + DECLARE_METHOD(EncapOCCI_Environment, ENVIRONMENT_SETEXCEPTIONS); + DECLARE_METHOD(EncapOCCI_Environment, ENVIRONMENT_GETERRORMSG); + DECLARE_METHOD(EncapOCCI_Environment, ENVIRONMENT_GETERRORCODE); DECLARE_METHOD(EncapOCCI_Environment, ENVIRONMENT_CREATECONNECTION); + DECLARE_METHOD(EncapOCCI_Environment, ENVIRONMENT_GETCACHEMAXSIZE); + DECLARE_METHOD(EncapOCCI_Environment, ENVIRONMENT_GETCACHEOPTSIZE); + DECLARE_METHOD(EncapOCCI_Environment, ENVIRONMENT_GETCURRENTHEAPSIZE); + DECLARE_METHOD(EncapOCCI_Environment, ENVIRONMENT_SETCACHEMAXSIZE); + DECLARE_METHOD(EncapOCCI_Environment, ENVIRONMENT_SETCACHEOPTSIZE); DECLARE_METHOD(EncapOCCI_Environment, ENVIRONMENT_TERMINATECONNECTION); DECLARE_FUNCTION(EncapOCCI_Environment, ENVIRONMENT_CREATEENVIRONMENT); @@ -85,7 +99,15 @@ class sLua_EncapOCCI_Environment : public Base { void LuaOCCI_Environment::pushmembers(Lua * L) { pushme(L, o, "OCCI_Environment"); + PUSH_METHOD(EncapOCCI_Environment, ENVIRONMENT_SETEXCEPTIONS); + PUSH_METHOD(EncapOCCI_Environment, ENVIRONMENT_GETERRORMSG); + PUSH_METHOD(EncapOCCI_Environment, ENVIRONMENT_GETERRORCODE); PUSH_METHOD(EncapOCCI_Environment, ENVIRONMENT_CREATECONNECTION); + PUSH_METHOD(EncapOCCI_Environment, ENVIRONMENT_GETCACHEMAXSIZE); + PUSH_METHOD(EncapOCCI_Environment, ENVIRONMENT_GETCACHEOPTSIZE); + PUSH_METHOD(EncapOCCI_Environment, ENVIRONMENT_GETCURRENTHEAPSIZE); + PUSH_METHOD(EncapOCCI_Environment, ENVIRONMENT_SETCACHEMAXSIZE); + PUSH_METHOD(EncapOCCI_Environment, ENVIRONMENT_SETCACHEOPTSIZE); PUSH_METHOD(EncapOCCI_Environment, ENVIRONMENT_TERMINATECONNECTION); } @@ -156,7 +178,12 @@ int sLua_EncapOCCI_Environment::EncapOCCI_Environment_proceed(Lua * L, int n, En try { r = EncapOCCI_Environment_proceed_unprotected(L, n, obj, caller); } catch (SQLException ex) { - L->error(String("Got an SQLException: ") + ex.what()); + if (obj->disableExceptions) { + obj->lastError_msg = ex.getMessage().c_str(); + obj->lastError_code = ex.getErrorCode(); + } else { + L->error(String("Got an SQLException: ") + ex.what()); + } } return r; @@ -169,6 +196,17 @@ int sLua_EncapOCCI_Environment::EncapOCCI_Environment_proceed_unprotected(Lua * String username, password, url; switch (caller) { + case ENVIRONMENT_SETEXCEPTIONS: + obj->disableExceptions = !L->toboolean(2); + break; + case ENVIRONMENT_GETERRORMSG: + L->push(obj->lastError_msg); + r = 1; + break; + case ENVIRONMENT_GETERRORCODE: + L->push((lua_Number) obj->lastError_code); + r = 1; + break; case ENVIRONMENT_CREATECONNECTION: username = L->tostring(2); password = L->tostring(3); @@ -178,6 +216,7 @@ int sLua_EncapOCCI_Environment::EncapOCCI_Environment_proceed_unprotected(Lua * url = L->tostring(4); conn = new EncapOCCI_Connection(env->createConnection(username.to_charp(), password.to_charp(), url.to_charp())); } + conn->disableExceptions = obj->disableExceptions; { LuaOCCI_Connection lconn(conn); lconn.pushdestruct(L); @@ -244,7 +283,10 @@ int sLua_EncapOCCI_Environment::EncapOCCI_Environment_proceed_statics(Lua * L, i /*** Connection bindings ***/ enum EncapOCCI_Connection_methods_t { - CONNECTION_CHANGEPASSWORD = 0, + CONNECTION_SETEXCEPTIONS = 0, + CONNECTION_GETERRORMSG, + CONNECTION_GETERRORCODE, + CONNECTION_CHANGEPASSWORD, CONNECTION_COMMIT, CONNECTION_CREATESTATEMENT, CONNECTION_FLUSHCACHE, @@ -256,6 +298,9 @@ enum EncapOCCI_Connection_methods_t { }; struct lua_functypes_t EncapOCCI_Connection_methods[] = { + { CONNECTION_SETEXCEPTIONS, "setExceptions", 1, 1, { BLUA_BOOLEAN } }, + { CONNECTION_GETERRORMSG, "getErrorMsg", 0, 0, { } }, + { CONNECTION_GETERRORCODE, "getErrorCode", 0, 0, { } }, { CONNECTION_CHANGEPASSWORD, "changePassword", 3, 3, { BLUA_STRING, BLUA_STRING, BLUA_STRING } }, { CONNECTION_COMMIT, "commit", 0, 0, { } }, { CONNECTION_CREATESTATEMENT, "createStatement", 0, 1, { BLUA_STRING } }, @@ -273,6 +318,9 @@ struct lua_functypes_t EncapOCCI_Connection_functions[] = { class sLua_EncapOCCI_Connection : public Base { public: + DECLARE_METHOD(EncapOCCI_Connection, CONNECTION_SETEXCEPTIONS); + DECLARE_METHOD(EncapOCCI_Connection, CONNECTION_GETERRORMSG); + DECLARE_METHOD(EncapOCCI_Connection, CONNECTION_GETERRORCODE); DECLARE_METHOD(EncapOCCI_Connection, CONNECTION_CHANGEPASSWORD); DECLARE_METHOD(EncapOCCI_Connection, CONNECTION_COMMIT); DECLARE_METHOD(EncapOCCI_Connection, CONNECTION_CREATESTATEMENT); @@ -291,6 +339,9 @@ class sLua_EncapOCCI_Connection : public Base { void LuaOCCI_Connection::pushmembers(Lua * L) { pushme(L, o, "OCCI_Connection"); + PUSH_METHOD(EncapOCCI_Connection, CONNECTION_SETEXCEPTIONS); + PUSH_METHOD(EncapOCCI_Connection, CONNECTION_GETERRORMSG); + PUSH_METHOD(EncapOCCI_Connection, CONNECTION_GETERRORCODE); PUSH_METHOD(EncapOCCI_Connection, CONNECTION_CHANGEPASSWORD); PUSH_METHOD(EncapOCCI_Connection, CONNECTION_COMMIT); PUSH_METHOD(EncapOCCI_Connection, CONNECTION_CREATESTATEMENT); @@ -312,7 +363,12 @@ int sLua_EncapOCCI_Connection::EncapOCCI_Connection_proceed(Lua * L, int n, Enca try { r = EncapOCCI_Connection_proceed_unprotected(L, n, obj, caller); } catch (SQLException ex) { - L->error(String("Got an SQLException: ") + ex.what()); + if (obj->disableExceptions) { + obj->lastError_msg = ex.getMessage().c_str(); + obj->lastError_code = ex.getErrorCode(); + } else { + L->error(String("Got an SQLException: ") + ex.what()); + } } return r; @@ -325,6 +381,17 @@ int sLua_EncapOCCI_Connection::EncapOCCI_Connection_proceed_unprotected(Lua * L, int r = 0; switch(caller) { + case CONNECTION_SETEXCEPTIONS: + obj->disableExceptions = !L->toboolean(2); + break; + case CONNECTION_GETERRORMSG: + L->push(obj->lastError_msg); + r = 1; + break; + case CONNECTION_GETERRORCODE: + L->push((lua_Number) obj->lastError_code); + r = 1; + break; case CONNECTION_CHANGEPASSWORD: user = L->tostring(2); oldpw = L->tostring(3); @@ -339,6 +406,7 @@ int sLua_EncapOCCI_Connection::EncapOCCI_Connection_proceed_unprotected(Lua * L, sql = L->tostring(2); } stmt = new EncapOCCI_Statement(conn->createStatement(sql.to_charp())); + stmt->disableExceptions = obj->disableExceptions; { LuaOCCI_Statement lstmt(stmt); lstmt.pushdestruct(L); @@ -381,7 +449,10 @@ int sLua_EncapOCCI_Connection::EncapOCCI_Connection_proceed_statics(Lua * L, int L->settable(LUA_GLOBALSINDEX); enum EncapOCCI_Statement_methods_t { - STATEMENT_ADDITERATION = 0, + STATEMENT_SETEXCEPTIONS = 0, + STATEMENT_GETERRORMSG, + STATEMENT_GETERRORCODE, + STATEMENT_ADDITERATION, STATEMENT_CLOSERESULTSET, STATEMENT_CLOSESTREAM, STATEMENT_EXECUTE, @@ -463,6 +534,9 @@ enum EncapOCCI_Statement_methods_t { }; struct lua_functypes_t EncapOCCI_Statement_methods[] = { + { STATEMENT_SETEXCEPTIONS, "setExceptions", 1, 1, { BLUA_BOOLEAN } }, + { STATEMENT_GETERRORMSG, "getErrorMsg", 0, 0, { } }, + { STATEMENT_GETERRORCODE, "getErrorCode", 0, 0, { } }, { STATEMENT_ADDITERATION, "addIteration", 0, 0, { } }, { STATEMENT_CLOSERESULTSET, "closeResultSet", 1, 1, { BLUA_OBJECT } }, { STATEMENT_CLOSESTREAM, "closeStream", 1, 1, { BLUA_OBJECT } }, @@ -528,6 +602,9 @@ struct lua_functypes_t EncapOCCI_Statement_functions[] = { class sLua_EncapOCCI_Statement : public Base { public: + DECLARE_METHOD(EncapOCCI_Statement, STATEMENT_SETEXCEPTIONS); + DECLARE_METHOD(EncapOCCI_Statement, STATEMENT_GETERRORMSG); + DECLARE_METHOD(EncapOCCI_Statement, STATEMENT_GETERRORCODE); DECLARE_METHOD(EncapOCCI_Statement, STATEMENT_ADDITERATION); DECLARE_METHOD(EncapOCCI_Statement, STATEMENT_CLOSERESULTSET); DECLARE_METHOD(EncapOCCI_Statement, STATEMENT_CLOSESTREAM); @@ -594,6 +671,9 @@ class sLua_EncapOCCI_Statement : public Base { void LuaOCCI_Statement::pushmembers(Lua * L) { pushme(L, o, "OCCI_Statement"); + PUSH_METHOD(EncapOCCI_Statement, STATEMENT_SETEXCEPTIONS); + PUSH_METHOD(EncapOCCI_Statement, STATEMENT_GETERRORMSG); + PUSH_METHOD(EncapOCCI_Statement, STATEMENT_GETERRORCODE); PUSH_METHOD(EncapOCCI_Statement, STATEMENT_ADDITERATION); PUSH_METHOD(EncapOCCI_Statement, STATEMENT_CLOSERESULTSET); PUSH_METHOD(EncapOCCI_Statement, STATEMENT_CLOSESTREAM); @@ -670,7 +750,12 @@ int sLua_EncapOCCI_Statement::EncapOCCI_Statement_proceed(Lua * L, int n, EncapO try { r = EncapOCCI_Statement_proceed_unprotected(L, n, obj, caller); } catch (SQLException ex) { - L->error(String("Got an SQLException: ") + ex.what()); + if (obj->disableExceptions) { + obj->lastError_msg = ex.getMessage().c_str(); + obj->lastError_code = ex.getErrorCode(); + } else { + L->error(String("Got an SQLException: ") + ex.what()); + } } return r; @@ -685,6 +770,17 @@ int sLua_EncapOCCI_Statement::EncapOCCI_Statement_proceed_unprotected(Lua * L, i String SQL; switch (caller) { + case STATEMENT_SETEXCEPTIONS: + obj->disableExceptions = !L->toboolean(2); + break; + case STATEMENT_GETERRORMSG: + L->push(obj->lastError_msg); + r = 1; + break; + case STATEMENT_GETERRORCODE: + L->push((lua_Number) obj->lastError_code); + r = 1; + break; case STATEMENT_ADDITERATION: stmt->addIteration(); break; @@ -715,11 +811,15 @@ int sLua_EncapOCCI_Statement::EncapOCCI_Statement_proceed_unprotected(Lua * L, i if (n == 1) { SQL = L->tostring(2); rset = stmt->executeQuery(SQL.to_charp()); - LuaOCCI_ResultSet lrset(new EncapOCCI_ResultSet(rset)); + EncapOCCI_ResultSet * erset = new EncapOCCI_ResultSet(rset); + erset->disableExceptions = obj->disableExceptions; + LuaOCCI_ResultSet lrset(erset); lrset.pushdestruct(L); } else { rset = stmt->executeQuery(); - LuaOCCI_ResultSet lrset(new EncapOCCI_ResultSet(rset)); + EncapOCCI_ResultSet * erset = new EncapOCCI_ResultSet(rset); + erset->disableExceptions = obj->disableExceptions; + LuaOCCI_ResultSet lrset(erset); lrset.pushdestruct(L); } r = 1; @@ -788,7 +888,9 @@ int sLua_EncapOCCI_Statement::EncapOCCI_Statement_proceed_unprotected(Lua * L, i case STATEMENT_GETCURSOR: { rset = stmt->getCursor(L->tonumber(2)); - LuaOCCI_ResultSet lrset(new EncapOCCI_ResultSet(rset)); + EncapOCCI_ResultSet * erset = new EncapOCCI_ResultSet(rset); + erset->disableExceptions = obj->disableExceptions; + LuaOCCI_ResultSet lrset(erset); lrset.pushdestruct(L); } r = 1; @@ -828,7 +930,9 @@ int sLua_EncapOCCI_Statement::EncapOCCI_Statement_proceed_unprotected(Lua * L, i case STATEMENT_GETRESULTSET: { rset = stmt->getResultSet(); - LuaOCCI_ResultSet lrset(new EncapOCCI_ResultSet(rset)); + EncapOCCI_ResultSet * erset = new EncapOCCI_ResultSet(rset); + erset->disableExceptions = obj->disableExceptions; + LuaOCCI_ResultSet lrset(erset); lrset.pushdestruct(L); } r = 1; @@ -855,7 +959,9 @@ int sLua_EncapOCCI_Statement::EncapOCCI_Statement_proceed_unprotected(Lua * L, i case STATEMENT_GETSTREAM: { strm = stmt->getStream(L->tonumber(2)); - LuaOCCI_Stream lstrm(new EncapOCCI_Stream(strm)); + EncapOCCI_Stream * estrm = new EncapOCCI_Stream(strm); + estrm->disableExceptions = obj->disableExceptions; + LuaOCCI_Stream lstrm(estrm); lstrm.pushdestruct(L); } r = 1; @@ -1011,6 +1117,9 @@ int sLua_EncapOCCI_Statement::EncapOCCI_Statement_proceed_unprotected(Lua * L, i L->settable(LUA_GLOBALSINDEX); enum EncapOCCI_ResultSet_methods_t { + RESULTSET_SETEXCEPTIONS = 0, + RESULTSET_GETERRORMSG, + RESULTSET_GETERRORCODE, RESULTSET_CANCEL, // RESULTSET_CLOSESTREAM, // RESULTSET_GETBFILE, @@ -1059,6 +1168,9 @@ enum EncapOCCI_ResultSet_methods_t { }; struct lua_functypes_t EncapOCCI_ResultSet_methods[] = { + { RESULTSET_SETEXCEPTIONS, "setExceptions", 1, 1, { BLUA_BOOLEAN } }, + { RESULTSET_GETERRORMSG, "getErrorMsg", 0, 0, { } }, + { RESULTSET_GETERRORCODE, "getErrorCode", 0, 0, { } }, { RESULTSET_CANCEL, "cancel", 0, 0, { } }, { RESULTSET_GETBLOB, "getBlob", 1, 1, { BLUA_NUMBER } }, { RESULTSET_GETBYTES, "getBytes", 1, 1, { BLUA_NUMBER } }, @@ -1099,6 +1211,9 @@ struct lua_functypes_t EncapOCCI_ResultSet_functions[] = { class sLua_EncapOCCI_ResultSet : public Base { public: + DECLARE_METHOD(EncapOCCI_ResultSet, RESULTSET_SETEXCEPTIONS); + DECLARE_METHOD(EncapOCCI_ResultSet, RESULTSET_GETERRORMSG); + DECLARE_METHOD(EncapOCCI_ResultSet, RESULTSET_GETERRORCODE); DECLARE_METHOD(EncapOCCI_ResultSet, RESULTSET_CANCEL); DECLARE_METHOD(EncapOCCI_ResultSet, RESULTSET_GETBLOB); DECLARE_METHOD(EncapOCCI_ResultSet, RESULTSET_GETBYTES); @@ -1140,6 +1255,9 @@ class sLua_EncapOCCI_ResultSet : public Base { void LuaOCCI_ResultSet::pushmembers(Lua * L) { pushme(L, o, "OCCI_ResultSet"); + PUSH_METHOD(EncapOCCI_ResultSet, RESULTSET_SETEXCEPTIONS); + PUSH_METHOD(EncapOCCI_ResultSet, RESULTSET_GETERRORMSG); + PUSH_METHOD(EncapOCCI_ResultSet, RESULTSET_GETERRORCODE); PUSH_METHOD(EncapOCCI_ResultSet, RESULTSET_CANCEL); PUSH_METHOD(EncapOCCI_ResultSet, RESULTSET_GETBLOB); PUSH_METHOD(EncapOCCI_ResultSet, RESULTSET_GETBYTES); @@ -1188,7 +1306,12 @@ int sLua_EncapOCCI_ResultSet::EncapOCCI_ResultSet_proceed(Lua * L, int n, EncapO try { r = EncapOCCI_ResultSet_proceed_unprotected(L, n, obj, caller); } catch (SQLException ex) { - L->error(String("Got an SQLException: ") + ex.what()); + if (obj->disableExceptions) { + obj->lastError_msg = ex.getMessage().c_str(); + obj->lastError_code = ex.getErrorCode(); + } else { + L->error(String("Got an SQLException: ") + ex.what()); + } } return r; @@ -1201,6 +1324,17 @@ int sLua_EncapOCCI_ResultSet::EncapOCCI_ResultSet_proceed_unprotected(Lua * L, i Stream * strm; switch (caller) { + case RESULTSET_SETEXCEPTIONS: + obj->disableExceptions = !L->toboolean(2); + break; + case RESULTSET_GETERRORMSG: + L->push(obj->lastError_msg); + r = 1; + break; + case RESULTSET_GETERRORCODE: + L->push((lua_Number) obj->lastError_code); + r = 1; + break; case RESULTSET_CANCEL: rset->cancel(); break; @@ -1251,7 +1385,9 @@ int sLua_EncapOCCI_ResultSet::EncapOCCI_ResultSet_proceed_unprotected(Lua * L, i case RESULTSET_GETCURSOR: { rset = rset->getCursor(L->tonumber(2)); - LuaOCCI_ResultSet lrset(new EncapOCCI_ResultSet(rset)); + EncapOCCI_ResultSet * erset = new EncapOCCI_ResultSet(rset); + erset->disableExceptions = obj->disableExceptions; + LuaOCCI_ResultSet lrset(erset); lrset.pushdestruct(L); } r = 1; @@ -1302,7 +1438,9 @@ int sLua_EncapOCCI_ResultSet::EncapOCCI_ResultSet_proceed_unprotected(Lua * L, i case RESULTSET_GETSTREAM: { strm = rset->getStream(L->tonumber(2)); - LuaOCCI_Stream lstrm(new EncapOCCI_Stream(strm)); + EncapOCCI_Stream * estrm = new EncapOCCI_Stream(strm); + estrm->disableExceptions = obj->disableExceptions; + LuaOCCI_Stream lstrm(estrm); lstrm.pushdestruct(L); } r = 1; @@ -1387,6 +1525,9 @@ int sLua_EncapOCCI_ResultSet::EncapOCCI_ResultSet_proceed_unprotected(Lua * L, i L->settable(LUA_GLOBALSINDEX); enum EncapOCCI_Stream_methods_t { + STREAM_SETEXCEPTIONS = 0, + STREAM_GETERRORMSG, + STREAM_GETERRORCODE, STREAM_READBUFFER, STREAM_READLASTBUFFER, STREAM_WRITEBUFFER, @@ -1395,6 +1536,9 @@ enum EncapOCCI_Stream_methods_t { }; struct lua_functypes_t EncapOCCI_Stream_methods[] = { + { STREAM_SETEXCEPTIONS, "setExceptions", 1, 1, { BLUA_BOOLEAN } }, + { STREAM_GETERRORMSG, "getErrorMsg", 0, 0, { } }, + { STREAM_GETERRORCODE, "getErrorCode", 0, 0, { } }, { STREAM_READBUFFER, "readBuffer", 1, 1, { BLUA_NUMBER } }, { STREAM_READLASTBUFFER, "readLastBuffer", 1, 1, { BLUA_NUMBER } }, { STREAM_WRITEBUFFER, "writeBuffer", 2, 2, { BLUA_OBJECT, BLUA_NUMBER } }, @@ -1409,6 +1553,9 @@ struct lua_functypes_t EncapOCCI_Stream_functions[] = { class sLua_EncapOCCI_Stream : public Base { public: + DECLARE_METHOD(EncapOCCI_Stream, STREAM_SETEXCEPTIONS); + DECLARE_METHOD(EncapOCCI_Stream, STREAM_GETERRORMSG); + DECLARE_METHOD(EncapOCCI_Stream, STREAM_GETERRORCODE); DECLARE_METHOD(EncapOCCI_Stream, STREAM_READBUFFER); DECLARE_METHOD(EncapOCCI_Stream, STREAM_READLASTBUFFER); DECLARE_METHOD(EncapOCCI_Stream, STREAM_WRITEBUFFER); @@ -1424,6 +1571,9 @@ class sLua_EncapOCCI_Stream : public Base { void LuaOCCI_Stream::pushmembers(Lua * L) { pushme(L, o, "OCCI_Stream"); + PUSH_METHOD(EncapOCCI_Stream, STREAM_SETEXCEPTIONS); + PUSH_METHOD(EncapOCCI_Stream, STREAM_GETERRORMSG); + PUSH_METHOD(EncapOCCI_Stream, STREAM_GETERRORCODE); PUSH_METHOD(EncapOCCI_Stream, STREAM_READBUFFER); PUSH_METHOD(EncapOCCI_Stream, STREAM_READLASTBUFFER); PUSH_METHOD(EncapOCCI_Stream, STREAM_WRITEBUFFER); @@ -1446,7 +1596,12 @@ int sLua_EncapOCCI_Stream::EncapOCCI_Stream_proceed(Lua * L, int n, EncapOCCI_St try { r = EncapOCCI_Stream_proceed_unprotected(L, n, obj, caller); } catch (SQLException ex) { - L->error(String("Got an SQLException: ") + ex.what()); + if (obj->disableExceptions) { + obj->lastError_msg = ex.getMessage().c_str(); + obj->lastError_code = ex.getErrorCode(); + } else { + L->error(String("Got an SQLException: ") + ex.what()); + } } return r; @@ -1461,6 +1616,17 @@ int sLua_EncapOCCI_Stream::EncapOCCI_Stream_proceed_unprotected(Lua * L, int n, Buffer * b; switch (caller) { + case STREAM_SETEXCEPTIONS: + obj->disableExceptions = !L->toboolean(2); + break; + case STREAM_GETERRORMSG: + L->push(obj->lastError_msg); + r = 1; + break; + case STREAM_GETERRORCODE: + L->push((lua_Number) obj->lastError_code); + r = 1; + break; case STREAM_READBUFFER: size = L->tonumber(2); if (size == -1) { |