From 2b19076a9f4325b42316983a0317f87a40864e78 Mon Sep 17 00:00:00 2001 From: Pixel Date: Tue, 14 Apr 2009 15:15:32 -0700 Subject: Adding a hack to have getFieldsInfo for OCCI's ResultSets; partial support of the MetaData call that is. --- lib/LuaOCCI.cc | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'lib') diff --git a/lib/LuaOCCI.cc b/lib/LuaOCCI.cc index 8c02e9f..df5ea66 100644 --- a/lib/LuaOCCI.cc +++ b/lib/LuaOCCI.cc @@ -1165,6 +1165,7 @@ enum EncapOCCI_ResultSet_methods_t { RESULTSET_STATUS, RESULTSET_SETBLOB, + RESULTSET_GETFIELDSINFO, }; struct lua_functypes_t EncapOCCI_ResultSet_methods[] = { @@ -1202,6 +1203,7 @@ struct lua_functypes_t EncapOCCI_ResultSet_methods[] = { { RESULTSET_STATUS, "status", 0, 0, { } }, { RESULTSET_SETBLOB, "setBlob", 2, 2, { BLUA_NUMBER, BLUA_OBJECT } }, + { RESULTSET_GETFIELDSINFO, "getFieldsInfo", 0, 0, { } }, { -1, 0, 0, 0, 0 }, }; @@ -1245,6 +1247,7 @@ class sLua_EncapOCCI_ResultSet : public Base { DECLARE_METHOD(EncapOCCI_ResultSet, RESULTSET_STATUS); DECLARE_METHOD(EncapOCCI_ResultSet, RESULTSET_SETBLOB); + DECLARE_METHOD(EncapOCCI_ResultSet, RESULTSET_GETFIELDSINFO); private: static int EncapOCCI_ResultSet_proceed(Lua * L, int n, EncapOCCI_ResultSet * obj, int caller); @@ -1289,6 +1292,7 @@ void LuaOCCI_ResultSet::pushmembers(Lua * L) { PUSH_METHOD(EncapOCCI_ResultSet, RESULTSET_STATUS); PUSH_METHOD(EncapOCCI_ResultSet, RESULTSET_SETBLOB); + PUSH_METHOD(EncapOCCI_ResultSet, RESULTSET_GETFIELDSINFO); } void LuaOCCI_ResultSet::pushstatics(Lua * L) throw (GeneralException) { @@ -1511,6 +1515,23 @@ int sLua_EncapOCCI_ResultSet::EncapOCCI_ResultSet_proceed_unprotected(Lua * L, i blob.closeStream(outstream); blob.close(); } + break; + case RESULTSET_GETFIELDSINFO: + { + std::vector meta = rset->getColumnListMetaData(); + L->push((lua_Number) meta.size()); + + int c = 1; + L->newtable(); + for (std::vector::iterator i = meta.begin(); i != meta.end(); i++, c++) { + L->push((lua_Number) c); + L->push(String(i->getString(MetaData::ATTR_NAME).c_str())); + L->settable(); + } + + r = 2; + } + break; } return r; -- cgit v1.2.3