From: <ibr...@us...> - 2010-10-06 14:07:28
|
Revision: 3739 http://tora.svn.sourceforge.net/tora/?rev=3739&view=rev Author: ibre5041 Date: 2010-10-06 14:07:21 +0000 (Wed, 06 Oct 2010) Log Message: ----------- sync with trotl trunk Modified Paths: -------------- branches/tora-trotl/src/trotl/src/trotl_collection.cpp branches/tora-trotl/src/trotl/src/trotl_collection.h branches/tora-trotl/src/trotl/src/trotl_convertor.cpp branches/tora-trotl/src/trotl/src/trotl_convertor.h branches/tora-trotl/src/trotl/src/trotl_lob.cpp branches/tora-trotl/src/trotl/src/trotl_lob.h branches/tora-trotl/src/trotl/src/trotl_var.cpp branches/tora-trotl/src/trotl/src/trotl_xml.cpp Modified: branches/tora-trotl/src/trotl/src/trotl_collection.cpp =================================================================== --- branches/tora-trotl/src/trotl/src/trotl_collection.cpp 2010-10-06 13:44:59 UTC (rev 3738) +++ branches/tora-trotl/src/trotl/src/trotl_collection.cpp 2010-10-06 14:07:21 UTC (rev 3739) @@ -216,11 +216,11 @@ bool comma=false; while(!eoc) { - OCINumber *ocinum = NULL; + void *field = NULL; void *elemind = NULL; res = OCICALL(OCIIterNext (_conn._env, _conn._env._errh, itr, - (void**) &ocinum, + (void**) &field, (void**) &elemind, //NULL, //void **elemind, &eoc)); oci_check_error(__TROTL_HERE__, _conn._env._errh, res); @@ -235,14 +235,14 @@ { _stringrepres << "NULL"; } else { - switch(_data_type) + switch(_collection_typecode) { case SQLT_NUM: { text str_buf[64]; ub4 str_len = sizeof(str_buf) / sizeof(*str_buf); sword res = OCICALL(OCINumberToText(_conn._env._errh, - (OCINumber*) ocinum, + (OCINumber*) field, (const oratext*) g_TROTL_DEFAULT_NUM_FTM, strlen(g_TROTL_DEFAULT_NUM_FTM), 0, // CONST OraText *nls_params, @@ -254,8 +254,13 @@ _stringrepres << tstring((const char*)str_buf, str_len); } break; + case SQLT_CHR: // NOTE: this is also valid for array of VARCHAR2 + { + _stringrepres << '\'' << OCIStringPtr(_conn._env, *(OCIString **)field) << '\''; + } + break; default: - throw OciException(__TROTL_HERE__, "Not implemented yet"); + throw OciException(__TROTL_HERE__, "Collection to string convertorsion - Not implemented yet"); } } } Modified: branches/tora-trotl/src/trotl/src/trotl_collection.h =================================================================== --- branches/tora-trotl/src/trotl/src/trotl_collection.h 2010-10-06 13:44:59 UTC (rev 3738) +++ branches/tora-trotl/src/trotl/src/trotl_collection.h 2010-10-06 14:07:21 UTC (rev 3739) @@ -56,6 +56,7 @@ BindParCollectionTabNum(unsigned int pos, SqlStatement &stmt, ColumnType &ct) : SqlStatement::BindPar(pos, stmt, ct) , _collection_indp(NULL) + , _collection_typecode(ct._collection_typecode) { valuep = (void**) calloc(_cnt, sizeof(void*)); value_sz = sizeof(OCIColl*); @@ -70,6 +71,7 @@ BindParCollectionTabNum(unsigned int pos, SqlStatement &stmt, BindVarDecl &decl) : SqlStatement::BindPar(pos, stmt, decl) , _collection_indp(NULL) + // , _collection_typecode(???) TODO { valuep = (void**) calloc(_cnt, sizeof(void*)); value_sz = sizeof(OCIColl*); @@ -92,6 +94,7 @@ //private: mutable std::stringstream _stringrepres; void **_collection_indp; + OCITypeCode _collection_typecode; OCIType *_collection_tdo; }; @@ -103,6 +106,7 @@ BindParCollectionTabVarchar(unsigned int pos, SqlStatement &stmt, ColumnType &ct) : SqlStatement::BindPar(pos, stmt, ct) , _collection_indp(NULL) + , _collection_typecode(ct._collection_typecode) { valuep = (void**) calloc(_cnt, sizeof(void*)); value_sz = sizeof(OCIColl*); @@ -116,7 +120,8 @@ BindParCollectionTabVarchar(unsigned int pos, SqlStatement &stmt, BindVarDecl &decl) : SqlStatement::BindPar(pos, stmt, decl) - , _collection_indp(NULL) + , _collection_indp(NULL) + // , _collection_typecode(???) TODO { valuep = (void**) calloc(_cnt, sizeof(void*)); value_sz = sizeof(OCIColl*); @@ -136,9 +141,10 @@ virtual void bind_hook(SqlStatement &stmt); -private: +//private: mutable std::stringstream _stringrepres; void **_collection_indp; + OCITypeCode _collection_typecode; OCIType *_collection_tdo; }; @@ -149,7 +155,9 @@ SqlCollection(OciConnection &conn) : _conn(conn) + , _collection_typecode(0) , _collection_tdo(NULL) + {} @@ -172,10 +180,9 @@ tstring _data_type_name; OCIColl *_valuep; + OCITypeCode _collection_typecode; OCIType *_collection_tdo; OCIInd _ind; - ub2 _data_type; - }; Modified: branches/tora-trotl/src/trotl/src/trotl_convertor.cpp =================================================================== --- branches/tora-trotl/src/trotl/src/trotl_convertor.cpp 2010-10-06 13:44:59 UTC (rev 3738) +++ branches/tora-trotl/src/trotl/src/trotl_convertor.cpp 2010-10-06 14:07:21 UTC (rev 3739) @@ -64,7 +64,7 @@ CL._ind = BP.indp[_row]; if(CL.is_not_null()) { - if(BP.is_temporary(_row)) + if(BP.isTemporary(_row)) { sword res = OCICALL(OCILobLocatorAssign(BP._stmt._conn._svc_ctx, BP._env._errh, ((OCILobLocator**)BP.valuep)[_row], &CL._loc)); oci_check_error(__TROTL_HERE__, BP._env._errh, res); @@ -83,7 +83,7 @@ BL._ind = BP.indp[_row]; if(BL.is_not_null()) { - if(BP.is_temporary(_row)) + if(BP.isTemporary(_row)) { sword res = OCICALL(OCILobLocatorAssign(BP._stmt._conn._svc_ctx, BP._env._errh, ((OCILobLocator**)BP.valuep)[_row], &BL._loc)); oci_check_error(__TROTL_HERE__, BP._env._errh, res); @@ -157,7 +157,7 @@ { sword res; SV._collection_tdo = BP._collection_tdo; - SV._data_type = SQLT_NUM; + SV._collection_typecode = BP._collection_typecode; SV._ind = *(sb2*)(BP._collection_indp[_row]); SV._data_type_name = BP.type_name; @@ -173,6 +173,27 @@ res = OCICALL(OCICollAssign(BP._stmt._env, BP._stmt._errh, (OCIColl*)BP.valuep[_row], SV._valuep)); oci_check_error(__TROTL_HERE__, BP._stmt._errh, res); } + +void ConvertorForRead::Fire(const BindParCollectionTabVarchar &BP, SqlCollection &SV) +{ + sword res; + SV._collection_tdo = BP._collection_tdo; + SV._collection_typecode = BP._collection_typecode; + SV._ind = *(sb2*)(BP._collection_indp[_row]); + SV._data_type_name = BP.type_name; + + res = OCICALL(OCIObjectNew(BP._stmt._env, BP._stmt._errh, BP._stmt._conn._svc_ctx, + OCI_TYPECODE_TABLE, // TabNum => Table + BP._collection_tdo, + NULL, // dvoid *table + OCI_DURATION_SESSION, + TRUE, // boolean value + (dvoid**) &SV._valuep)); + oci_check_error(__TROTL_HERE__, BP._stmt._errh, res); + + res = OCICALL(OCICollAssign(BP._stmt._env, BP._stmt._errh, (OCIColl*)BP.valuep[_row], SV._valuep)); + oci_check_error(__TROTL_HERE__, BP._stmt._errh, res); +} // TODO this needs to be tested void ConvertorForWrite::Fire(const SqlDateTime &DT, BindParDate &BP) Modified: branches/tora-trotl/src/trotl/src/trotl_convertor.h =================================================================== --- branches/tora-trotl/src/trotl/src/trotl_convertor.h 2010-10-06 13:44:59 UTC (rev 3738) +++ branches/tora-trotl/src/trotl/src/trotl_convertor.h 2010-10-06 14:07:21 UTC (rev 3739) @@ -138,7 +138,7 @@ void Fire(const BindParCollectionTabVarchar &BP, SqlBlob &SV) { OnError(BP, SV); }; void Fire(const BindParCollectionTabVarchar &BP, SqlDateTime &SV) { OnError(BP, SV); }; void Fire(const BindParCollectionTabVarchar &BP, SqlNumber &SV) { OnError(BP, SV); }; - void Fire(const BindParCollectionTabVarchar &BP, SqlCollection &SV) { OnError(BP, SV); }; + void Fire(const BindParCollectionTabVarchar &BP, SqlCollection &SV); #ifdef ORACLE_HAS_XML void Fire(const BindParCollectionTabVarchar &BP, SqlXML &SV) { OnError(BP, SV); }; #endif Modified: branches/tora-trotl/src/trotl/src/trotl_lob.cpp =================================================================== --- branches/tora-trotl/src/trotl/src/trotl_lob.cpp 2010-10-06 13:44:59 UTC (rev 3738) +++ branches/tora-trotl/src/trotl/src/trotl_lob.cpp 2010-10-06 14:07:21 UTC (rev 3739) @@ -137,13 +137,22 @@ // oci_check_error(__TROTL_HERE__, _env, res); } -boolean BindParLob::is_temporary(unsigned _row) const +boolean BindParLob::isTemporary(unsigned _row) const { boolean flag; sword res = OCICALL(OCILobIsTemporary(_env, _env._errh, ((OCILobLocator**)valuep)[_row], &flag)); oci_check_error(__TROTL_HERE__, _env._errh, res); return flag; } + +ub4 BindParLob::getChunkSize(unsigned _row) const +{ + ub4 retval; + sword res = OCICALL(OCILobGetChunkSize(_stmt._conn._svc_ctx, _env._errh, ((OCILobLocator**)valuep)[_row], &retval)); + oci_check_error(__TROTL_HERE__, _env._errh, res); + return retval; + +} BindParClob::BindParClob(unsigned int pos, SqlStatement &stmt, ColumnType &ct) : BindParLob(pos, stmt, ct) { @@ -203,7 +212,7 @@ { // According to the Oracle 10g documentation we should try to free // implicit created temporary LOBs as soon as possible. - if (is_temporary()) { + if (isTemporary()) { sword res = OCICALL(OCILobFreeTemporary(_conn._svc_ctx, _conn._env._errh, _loc)); oci_check_error(__TROTL_HERE__, _conn._env._errh, res); } @@ -256,7 +265,7 @@ return flag; }; -boolean SqlLob::is_temporary() const +boolean SqlLob::isTemporary() const { boolean flag; sword res = OCICALL(OCILobIsTemporary(_conn._env, _conn._env._errh, _loc, &flag)); @@ -351,9 +360,9 @@ ub4 SqlBlob::read(dvoid* bufp, ub4 buflen, ub4 offset, ub4 amount) { sword res = OCICALL(OCILobRead(_conn._svc_ctx, _conn._env._errh, _loc, - &amount, offset, bufp, buflen, - NULL/*dvoid* ctxp*/, NULL/*sb4 (*cbfp)(dvoid*ctxp,CONST dvoid*bufp,ub4*len,ub1*piece)*/, - 0, 0)); + &amount, offset, bufp, buflen, + NULL/*dvoid* ctxp*/, NULL/*sb4 (*cbfp)(dvoid*ctxp,CONST dvoid*bufp,ub4*len,ub1*piece)*/, + 0, 0)); oci_check_error(__TROTL_HERE__, _conn._env._errh, res); return amount; }; Modified: branches/tora-trotl/src/trotl/src/trotl_lob.h =================================================================== --- branches/tora-trotl/src/trotl/src/trotl_lob.h 2010-10-06 13:44:59 UTC (rev 3738) +++ branches/tora-trotl/src/trotl/src/trotl_lob.h 2010-10-06 14:07:21 UTC (rev 3739) @@ -56,8 +56,9 @@ virtual void bind_hook(SqlStatement &stmt); virtual void define_hook(SqlStatement &stmt); - boolean is_temporary(unsigned _row) const; - + boolean isTemporary(unsigned row) const; + ub4 getChunkSize(unsigned row) const; + private: void descAlloc(void); //TODO OCI_DTYPE_FILE for BFILE, CFILE void descFree(void); @@ -116,7 +117,7 @@ boolean is_open() const; - boolean is_temporary() const; + boolean isTemporary() const; void copy(const SqlLob& src, ub4 amount, ub4 dst_offset, ub4 src_offset); @@ -124,7 +125,7 @@ void trim(ub4 newlen=0); - ub4 erase(ub4 offset, ub4 amount); + ub4 erase(ub4 offset, ub4 amount); void enable_buffering(); Modified: branches/tora-trotl/src/trotl/src/trotl_var.cpp =================================================================== --- branches/tora-trotl/src/trotl/src/trotl_var.cpp 2010-10-06 13:44:59 UTC (rev 3738) +++ branches/tora-trotl/src/trotl/src/trotl_var.cpp 2010-10-06 14:07:21 UTC (rev 3739) @@ -285,7 +285,7 @@ break; } case SQLT_LNG: - _width = g_OCIPL_MAX_LONG; //TODO long can have up to 2GB + _width = g_OCIPL_MAX_LONG; //TODO long can have up to 2GB, use callback define break; case SQLT_CHR: case SQLT_STR: Modified: branches/tora-trotl/src/trotl/src/trotl_xml.cpp =================================================================== --- branches/tora-trotl/src/trotl/src/trotl_xml.cpp 2010-10-06 13:44:59 UTC (rev 3738) +++ branches/tora-trotl/src/trotl/src/trotl_xml.cpp 2010-10-06 14:07:21 UTC (rev 3739) @@ -34,12 +34,13 @@ #include "trotl_xml.h" #include <string.h> + namespace trotl { Util::RegisterInFactory<BindParXML, BindParFactTwoParmSing> regBindXML("SYS.XMLTYPE"); Util::RegisterInFactory<BindParXML, CustDefineParFactTwoParmSing> regCustDefineNTY_XML("SYS.XMLTYPE"); - + void BindParXML::init(SqlStatement &stmt) { sword res; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |