diff options
author | pixel <pixel> | 2008-05-18 21:42:37 +0000 |
---|---|---|
committer | pixel <pixel> | 2008-05-18 21:42:37 +0000 |
commit | b4ed40f18ae5ba01ffb515ea42417a030e9b01ec (patch) | |
tree | 12f65dff1eaa3bea5eb7337ed4e44ddfb51326a2 /lib | |
parent | 9bdc1ce0c516f6706e580770d9016b60b7a6e1ab (diff) |
Adding getNumber and setNumber methods.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/LuaOCCI.cc | 43 |
1 files changed, 40 insertions, 3 deletions
diff --git a/lib/LuaOCCI.cc b/lib/LuaOCCI.cc index f9f48d1..f6e2501 100644 --- a/lib/LuaOCCI.cc +++ b/lib/LuaOCCI.cc @@ -5,6 +5,8 @@ using namespace oracle::occi; +static Environment * global_env = 0; + template<class T> T * lua_recast(Lua * L, int n = 1) { Base * b; @@ -217,6 +219,9 @@ int sLua_EncapOCCI_Environment::EncapOCCI_Environment_proceed_statics(Lua * L, i switch (caller) { case ENVIRONMENT_CREATEENVIRONMENT: env = new EncapOCCI_Environment(Environment::createEnvironment(Environment::DEFAULT)); + if (!global_env) { + global_env = env->Get(); + } { LuaOCCI_Environment lenv(env); lenv.pushdestruct(L); @@ -402,7 +407,7 @@ enum EncapOCCI_Statement_methods_t { // STATEMENT_GETINTERVALYM, STATEMENT_GETMAXITERATIONS, STATEMENT_GETMAXPARAMSIZE, -// STATEMENT_GETNUMBER, + STATEMENT_GETNUMBER, // STATEMENT_GETOBJECT, // STATEMENT_GETOCISTATEMENT, // STATEMENT_GETREF, @@ -442,7 +447,7 @@ enum EncapOCCI_Statement_methods_t { STATEMENT_SETMAXITERATIONS, STATEMENT_SETMAXPARAMSIZE, STATEMENT_SETNULL, -// STATEMENT_SETNUMBER, + STATEMENT_SETNUMBER, // STATEMENT_SETOBJECT, STATEMENT_SETPREFETCHMEMORYSIZE, STATEMENT_SETPREFETCHROWCOUNT, @@ -479,6 +484,7 @@ struct lua_functypes_t EncapOCCI_Statement_methods[] = { { STATEMENT_GETINT, "getInt", 1, 1, { BLUA_NUMBER } }, { STATEMENT_GETMAXITERATIONS, "getMaxIterations", 0, 0, { } }, { STATEMENT_GETMAXPARAMSIZE, "getMaxParamSize", 1, 1, { BLUA_NUMBER } }, + { STATEMENT_GETNUMBER, "getNumber", 1, 2, { BLUA_NUMBER, BLUA_STRING } }, { STATEMENT_GETRESULTSET, "getResultSet", 0, 0, { } }, { STATEMENT_GETROWID, "getRowid", 1, 1, { BLUA_NUMBER } }, { STATEMENT_GETSQL, "getSQL", 0, 0, { } }, @@ -505,6 +511,7 @@ struct lua_functypes_t EncapOCCI_Statement_methods[] = { { STATEMENT_SETMAXITERATIONS, "setMaxIterations", 1, 1, { BLUA_NUMBER } }, { STATEMENT_SETMAXPARAMSIZE, "setMaxParamSize", 2, 2, { BLUA_NUMBER, BLUA_NUMBER } }, { STATEMENT_SETNULL, "setNull", 2, 2, { BLUA_NUMBER, BLUA_NUMBER } }, + { STATEMENT_SETNUMBER, "setNumber", 2, 3, { BLUA_NUMBER, BLUA_STRING, BLUA_STRING } }, { STATEMENT_SETPREFETCHMEMORYSIZE, "setPrefetchMemorySize", 1, 1, { BLUA_NUMBER } }, { STATEMENT_SETPREFETCHROWCOUNT, "setPrefetchRowCount", 1, 1, { BLUA_NUMBER } }, { STATEMENT_SETROWID, "SetRowid", 2, 2, { BLUA_NUMBER, BLUA_OBJECT } }, @@ -542,6 +549,7 @@ class sLua_EncapOCCI_Statement : public Base { DECLARE_METHOD(EncapOCCI_Statement, STATEMENT_GETINT); DECLARE_METHOD(EncapOCCI_Statement, STATEMENT_GETMAXITERATIONS); DECLARE_METHOD(EncapOCCI_Statement, STATEMENT_GETMAXPARAMSIZE); + DECLARE_METHOD(EncapOCCI_Statement, STATEMENT_GETNUMBER); DECLARE_METHOD(EncapOCCI_Statement, STATEMENT_GETRESULTSET); DECLARE_METHOD(EncapOCCI_Statement, STATEMENT_GETROWID); DECLARE_METHOD(EncapOCCI_Statement, STATEMENT_GETSQL); @@ -568,6 +576,7 @@ class sLua_EncapOCCI_Statement : public Base { DECLARE_METHOD(EncapOCCI_Statement, STATEMENT_SETMAXITERATIONS); DECLARE_METHOD(EncapOCCI_Statement, STATEMENT_SETMAXPARAMSIZE); DECLARE_METHOD(EncapOCCI_Statement, STATEMENT_SETNULL); + DECLARE_METHOD(EncapOCCI_Statement, STATEMENT_SETNUMBER); DECLARE_METHOD(EncapOCCI_Statement, STATEMENT_SETPREFETCHMEMORYSIZE); DECLARE_METHOD(EncapOCCI_Statement, STATEMENT_SETPREFETCHROWCOUNT); DECLARE_METHOD(EncapOCCI_Statement, STATEMENT_SETROWID); @@ -606,6 +615,7 @@ void LuaOCCI_Statement::pushmembers(Lua * L) { PUSH_METHOD(EncapOCCI_Statement, STATEMENT_GETINT); PUSH_METHOD(EncapOCCI_Statement, STATEMENT_GETMAXITERATIONS); PUSH_METHOD(EncapOCCI_Statement, STATEMENT_GETMAXPARAMSIZE); + PUSH_METHOD(EncapOCCI_Statement, STATEMENT_GETNUMBER); PUSH_METHOD(EncapOCCI_Statement, STATEMENT_GETRESULTSET); PUSH_METHOD(EncapOCCI_Statement, STATEMENT_GETROWID); PUSH_METHOD(EncapOCCI_Statement, STATEMENT_GETSQL); @@ -632,6 +642,7 @@ void LuaOCCI_Statement::pushmembers(Lua * L) { PUSH_METHOD(EncapOCCI_Statement, STATEMENT_SETMAXITERATIONS); PUSH_METHOD(EncapOCCI_Statement, STATEMENT_SETMAXPARAMSIZE); PUSH_METHOD(EncapOCCI_Statement, STATEMENT_SETNULL); + PUSH_METHOD(EncapOCCI_Statement, STATEMENT_SETNUMBER); PUSH_METHOD(EncapOCCI_Statement, STATEMENT_SETPREFETCHMEMORYSIZE); PUSH_METHOD(EncapOCCI_Statement, STATEMENT_SETPREFETCHROWCOUNT); PUSH_METHOD(EncapOCCI_Statement, STATEMENT_SETROWID); @@ -806,6 +817,14 @@ int sLua_EncapOCCI_Statement::EncapOCCI_Statement_proceed_unprotected(Lua * L, i L->push((lua_Number) stmt->getMaxParamSize(L->tonumber(2))); r = 1; break; + case STATEMENT_GETNUMBER: + { + Number x = rset->getNumber(L->tonumber(2)); + std::string s = x.toText(global_env, n == 2 ? L->tostring(3).to_charp() : "TM9"); + L->push(String(s.c_str())); + } + r = 1; + break; case STATEMENT_GETRESULTSET: { rset = stmt->getResultSet(); @@ -933,6 +952,13 @@ int sLua_EncapOCCI_Statement::EncapOCCI_Statement_proceed_unprotected(Lua * L, i case STATEMENT_SETNULL: stmt->setNull(L->tonumber(2), (Type) L->tonumber(3)); break; + case STATEMENT_SETNUMBER: + { + Number x; + x.fromText(global_env, L->tostring(3).to_charp(), n == 3 ? L->tostring(4).to_charp() : "TM9"); + stmt->setNumber(L->tonumber(2), x); + } + break; case STATEMENT_SETPREFETCHMEMORYSIZE: stmt->setPrefetchMemorySize(L->tonumber(2)); break; @@ -993,7 +1019,7 @@ enum EncapOCCI_ResultSet_methods_t { // RESULTSET_GETINTERVALYM, RESULTSET_GETMAXCOLUMNSIZE, RESULTSET_GETNUMARRAYROWS, -// RESULTSET_GETNUMBER, + RESULTSET_GETNUMBER, // RESULTSET_GETOBJECT, // RESULTSET_GETREF, RESULTSET_GETROWID, @@ -1034,6 +1060,7 @@ struct lua_functypes_t EncapOCCI_ResultSet_methods[] = { { RESULTSET_GETINT, "getInt", 1, 1, { BLUA_NUMBER } }, { RESULTSET_GETMAXCOLUMNSIZE, "getMaxColumnSize", 1, 1, { BLUA_NUMBER } }, { RESULTSET_GETNUMARRAYROWS, "getNumArrayRows", 0, 0, { } }, + { RESULTSET_GETNUMBER, "getNumber", 1, 2, { BLUA_NUMBER, BLUA_STRING } }, { RESULTSET_GETROWID, "getRowid", 1, 1, { BLUA_NUMBER } }, { RESULTSET_GETSTREAM, "getStream", 1, 1, { BLUA_NUMBER } }, { RESULTSET_GETSTRING, "getString", 1, 1, { BLUA_NUMBER } }, @@ -1073,6 +1100,7 @@ class sLua_EncapOCCI_ResultSet : public Base { DECLARE_METHOD(EncapOCCI_ResultSet, RESULTSET_GETINT); DECLARE_METHOD(EncapOCCI_ResultSet, RESULTSET_GETMAXCOLUMNSIZE); DECLARE_METHOD(EncapOCCI_ResultSet, RESULTSET_GETNUMARRAYROWS); + DECLARE_METHOD(EncapOCCI_ResultSet, RESULTSET_GETNUMBER); DECLARE_METHOD(EncapOCCI_ResultSet, RESULTSET_GETROWID); DECLARE_METHOD(EncapOCCI_ResultSet, RESULTSET_GETSTREAM); DECLARE_METHOD(EncapOCCI_ResultSet, RESULTSET_GETSTRING); @@ -1113,6 +1141,7 @@ void LuaOCCI_ResultSet::pushmembers(Lua * L) { PUSH_METHOD(EncapOCCI_ResultSet, RESULTSET_GETINT); PUSH_METHOD(EncapOCCI_ResultSet, RESULTSET_GETMAXCOLUMNSIZE); PUSH_METHOD(EncapOCCI_ResultSet, RESULTSET_GETNUMARRAYROWS); + PUSH_METHOD(EncapOCCI_ResultSet, RESULTSET_GETNUMBER); PUSH_METHOD(EncapOCCI_ResultSet, RESULTSET_GETROWID); PUSH_METHOD(EncapOCCI_ResultSet, RESULTSET_GETSTREAM); PUSH_METHOD(EncapOCCI_ResultSet, RESULTSET_GETSTRING); @@ -1236,6 +1265,14 @@ int sLua_EncapOCCI_ResultSet::EncapOCCI_ResultSet_proceed_unprotected(Lua * L, i L->push((lua_Number) rset->getNumArrayRows()); r = 1; break; + case RESULTSET_GETNUMBER: + { + Number x = rset->getNumber(L->tonumber(2)); + std::string s = x.toText(global_env, n == 2 ? L->tostring(3).to_charp() : "TM9"); + L->push(String(s.c_str())); + } + r = 1; + break; case RESULTSET_GETROWID: { Bytes bytes = rset->getRowid(L->tonumber(2)); |