From: <ibr...@us...> - 2009-10-01 18:25:14
|
Revision: 3327 http://tora.svn.sourceforge.net/tora/?rev=3327&view=rev Author: ibre5041 Date: 2009-10-01 18:24:54 +0000 (Thu, 01 Oct 2009) Log Message: ----------- better handling for CLOBs, BLOBs, XMLs Modified Paths: -------------- branches/tora-trotl/src/tooracleconnection.cpp Modified: branches/tora-trotl/src/tooracleconnection.cpp =================================================================== --- branches/tora-trotl/src/tooracleconnection.cpp 2009-10-01 18:16:16 UTC (rev 3326) +++ branches/tora-trotl/src/tooracleconnection.cpp 2009-10-01 18:24:54 UTC (rev 3327) @@ -260,8 +260,7 @@ } else { switch(BP.dty) { case SQLT_NUM: - case SQLT_VNU: - { + case SQLT_VNU: { OCINumber* vnu = (OCINumber*) &((char*)BP.valuep)[_last_buff_row * BP.value_sz ]; sword res; boolean isint; @@ -288,8 +287,30 @@ value = toQValue(d); get_log().ts( std::string(__HERE__)) << "Just read: " << d << std::endl; } + } break; + case SQLT_NTY: { // NOTE: Only one SQLT_NTY is supported - SYS.XMLTYPE + ::trotl::BindParXML const *bpx = dynamic_cast<const trotl::BindParXML *>(&BP); + assert(bpx); + if((xmlnode*)bpx->_xmlvaluep[_last_buff_row] == NULL) + { + value = toQValue(); + get_log().ts( std::string(__HERE__)) << "Just read: NULL XML" << std::endl; + } else { + std::string s(BP.get_string(_last_buff_row)); + value = toQValue(QString(s.c_str())); + get_log().ts( std::string(__HERE__)) << "Just read: \"" << s << "\"" << std::endl; + } } + break; + case SQLT_CLOB: { + value = toQValue(QString("<CLOB>")); + } + break; + case SQLT_BLOB: { + value = toQValue(QString("<BLOB>")); + } + break; default: std::string s(BP.get_string(_last_buff_row)); value = toQValue(QString(s.c_str())); @@ -331,40 +352,40 @@ Query->readValue(retval); return retval; - const oracleQuery::trotlQuery::BindPar& bp( - Query->_stmt_type == OCI_STMT_SELECT ? - Query->get_curr_column() : Query->get_curr_out_bindpar()); - try { - switch(bp.dty) { - case SQLT_NUM: - case SQLT_VNU: - { - int i; - (*Query) >> i; - get_log().ts( std::string(__HERE__)) << - "d:\t" << bp.dty << - "\ti:\t'" << i << '\'' << std::endl; - return toQValue(i); - } - default: - { - std::string val; - (*Query) >> val; - get_log().ts( std::string(__HERE__)) << - "d:\t" << bp.dty << - "\ts:\t'" << val << '\'' << std::endl; - return toQValue(val.c_str()); - } - } - } catch (::trotl::OciException e) { - get_log().ts( std::string(__HERE__)) << - e.what() << std::endl; - return QString(); - } catch (...) { - get_log().ts( std::string(__HERE__)) << - "Unknown exception" << std::endl; - return QString(); - } +// const oracleQuery::trotlQuery::BindPar& bp( +// Query->_stmt_type == OCI_STMT_SELECT ? +// Query->get_curr_column() : Query->get_curr_out_bindpar()); +// try { +// switch(bp.dty) { +// case SQLT_NUM: +// case SQLT_VNU: +// { +// int i; +// (*Query) >> i; +// get_log().ts( std::string(__HERE__)) << +// "d:\t" << bp.dty << +// "\ti:\t'" << i << '\'' << std::endl; +// return toQValue(i); +// } +// default: +// { +// std::string val; +// (*Query) >> val; +// get_log().ts( std::string(__HERE__)) << +// "d:\t" << bp.dty << +// "\ts:\t'" << val << '\'' << std::endl; +// return toQValue(val.c_str()); +// } +// } +// } catch (::trotl::OciException e) { +// get_log().ts( std::string(__HERE__)) << +// e.what() << std::endl; +// return QString(); +// } catch (...) { +// get_log().ts( std::string(__HERE__)) << +// "Unknown exception" << std::endl; +// return QString(); +// } /* @@ -538,7 +559,7 @@ } try { bool e = Query->eof(); - get_log().ts( std::string(__HERE__)) << "eof - (2) " << e << std::endl; + get_log().ts( std::string(__HERE__)) << "eof - (2) " << Query->row_count() << '\t' << e << std::endl; return e; //Query->eof(); } catch (const ::trotl::OciException &exc) @@ -603,148 +624,7 @@ ret.insert(ret.end(), desc); } -// for (int i = 0;i < descriptionLen;i++) -// { -// toQuery::queryDescribe desc; -// desc.AlignRight = false; -// desc.Name = QString::fromUtf8(description[i].name); -// /* -// * http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10758/sqlqr06.htm -// * include ocidfn.h -// */ -// switch (description[i].dbtype) -// { -// case 1: /* VARCHAR2, NVARCHAR2 SQLT_CHR */ -// desc.Datatype = QString::fromLatin1("VARCHAR2(%i)"); -// datatypearg1 = description[i].char_size; -// #ifdef OTL_ORA_UNICODE -// if (description[i].charset_form == 2) -// { -// desc.Datatype = QString::fromLatin1("N") + desc.Datatype; -// } -// #endif -// break; -// case 2: /* NUMBER SQLT_NUM */ -// desc.Datatype = QString::fromLatin1("NUMBER"); - -// if (description[i].prec) -// { -// desc.Datatype = QString::fromLatin1("NUMBER(%i)"); -// datatypearg1 = description[i].prec; -// if (description[i].scale != 0) -// { -// desc.Datatype = QString::fromLatin1("NUMBER(%i,%i)"); -// datatypearg2 = description[i].scale; -// } -// } -// desc.AlignRight = true; -// break; - -// case 8: /* LONG SQLT_LNG */ -// desc.Datatype = QString::fromLatin1("LONG"); -// break; - -// case 12: /* DATE SQLT_DAT */ -// desc.Datatype = QString::fromLatin1("DATE"); -// desc.AlignRight = true; -// break; - -// case 23: /* RAW SQL_BIN */ -// desc.Datatype = QString::fromLatin1("RAW(%i)"); -// datatypearg1 = description[i].dbsize; -// break; - -// case 24: /* LONG RAW SQLT_LBI */ -// desc.Datatype = QString::fromLatin1("LONG RAW"); -// break; - -// case 104: /* ROWID, docu: 69, ocidfn.h: 104 SQLT_RDD */ -// case 208: /* UROWID */ -// desc.Datatype = QString::fromLatin1("ROWID"); -// break; - -// case 96: /* CHAR, NCHAR SQLT_AFC */ -// desc.Datatype = QString::fromLatin1("CHAR(%i)"); -// datatypearg1 = description[i].char_size; -// #ifdef OTL_ORA_UNICODE -// if (description[i].charset_form == 2) -// { -// desc.Datatype = QString::fromLatin1("N") + desc.Datatype; -// } -// #endif -// break; -// #ifdef OTL_ORA_NATIVE_TYPES -// case 100: /* BINARY_FLOAT SQLT_IBFLOAT */ -// desc.Datatype = QString::fromLatin1("BINARY_FLOAT"); -// break; - -// case 101: /* BINARY_DOUBLE SQLT_IBDOUBLE */ -// desc.Datatype = QString::fromLatin1("BINARY_DOUBLE"); -// break; -// #endif -// case 112: /* CLOB, NCLOB SQLT_CLOB */ -// desc.Datatype = QString::fromLatin1("CLOB"); -// #ifdef OTL_ORA_UNICODE -// if (description[i].charset_form == 2) -// { -// desc.Datatype = QString::fromLatin1("N") + desc.Datatype; -// } -// #endif -// break; - -// case 113: /* BLOB SQLT_BLOB */ -// desc.Datatype = QString::fromLatin1("BLOB"); -// break; -// #ifdef OTL_ORA_TIMESTAMP -// case 187: /* TIMESTAMP, docu: 180, ocidfn.h: 187 SQLT_TIMESTAMP SQLT_TIMESTAMP */ -// desc.Datatype = QString::fromLatin1("TIMESTAMP(%i)"); -// datatypearg1 = description[i].scale; -// break; - -// case 188: /* TIMESTAMP WITH TIME ZONE, docu: 181, ocidfn.h: 188 SQLT_INTERVAL_TZ */ -// desc.Datatype = QString::fromLatin1("TIMESTAMP(%i) WITH TIME ZONE"); -// datatypearg1 = description[i].scale; -// break; - -// case 189: /* INTERVAL YEAR TO MONTH, docu: 182, ocidfn.h: 189 SQLT_INTERVAL_YM */ -// desc.Datatype = QString::fromLatin1("INTERVAL YEAR(%i) TO MONTH"); -// datatypearg1 = description[i].prec; -// break; - -// case 190: /* INTERVAL DAY TO SECOND, docu: 183, ocidfn.h: 190 SQLT_INTERVAL_DS */ -// desc.Datatype = QString::fromLatin1("INTERVAL DAY(%i) TO SECOND(%i)"); -// datatypearg1 = description[i].prec; -// datatypearg2 = description[i].scale; -// break; - -// case 232: /* TIMESTAMP WITH LOCAL TIME ZONE docu: 231, ocidfn.h: 232 SQLT_TIMESTAMP_LTZ */ -// desc.Datatype = QString::fromLatin1("TIMESTAMP(%i) WITH LOCAL TIME ZONE"); -// datatypearg1 = description[i].scale; -// break; -// #endif -// default: -// desc.Datatype = QString::fromLatin1("UNKNOWN"); - -// /* report unmatched datatypes for adding later */ -// printf("File a bug report and include the table layout and the following data:\n"); -// printf(" type=%i, otl_type=%i, size=%i, nullok=%i, charset_form=%i, charset_size=%i, prec=%i, scale=%i\n", -// description[i].dbtype, -// description[i].otl_var_dbtype, -// description[i].dbsize, -// description[i].nullok, -// description[i].charset_form, -// description[i].char_size, -// description[i].prec, -// description[i].scale); -// } -// desc.Datatype.sprintf(desc.Datatype.toUtf8().constData(), datatypearg1, datatypearg2); - -// desc.Null = description[i].nullok; - -// ret.insert(ret.end(), desc); -// } - return ret; } }; // class oracleQuery : public toQuery::queryImpl This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |