I mentioned before about the
SOCI project. Recently, I was planning to adopt the library(version 2.2.0) into my project. However, while using the library to connect to
Oracle 9i, I encountered a weird exception. The trouble I had was if I use soci::use(std::string) for more than one time in a sql query, then I get ORA-01460 error. For example, I used the following code to reproduce the error.
std::string prodid1("2330"), prodid2("2885");
SOCI::Row r;
SOCI::Statement st = (sql.prepare <<
"select * from product where prodid in (:prodid1, :prodid2)",
SOCI::use(prodid1), SOCI::use(prodid2),
SOCI::into(r));
It seemed related to the binding process in the function soci::StandardUseType::bind. After tweaking the source code for a while, I found by modifying the fuction definition as follows, the error was gone.
void OracleStandardUseTypeBackEnd::prepareForBind(
void *&data, sb4 &size, ub2 &oracleType)
{
...
case eXStdString:
oracleType = SQLT_STR;
// 4000 is Oracle max VARCHAR2 size; 32768 is max LONG size
//size = 32769;
size =sizeof(static_cast<std::string *>(data)->c_str());
...
}
No comments:
Post a Comment