Does Oracle occi have any memory bugs when writing blobs using stored procedures via stream?
The function below will produce some kind of memory corruption that will cause an exception (which cannot be identified since memory is corrupted) while doing another call:
{
ora::Statement stmt(__cn);
string sql("BEGIN Pckg.Sp_procA(:1, :2, :3, :4, :5, :6, :7, :8, "
":9, :10, :11, :12, :13, :14, :15, :payload); END;");
occi::Blob payload(__cn.getConnection());
occi::Environment* tempEnv = occi::Environment::createEnvironment();
occi::Timestamp reportTime(tempEnv);
reportTime.fromText(__report.report_time), "yyyy-mm-ddH24:mi:ss.ff");
stmt.setSQL(sql);
stmt.setString (1, "");
stmt.setString (2, "");
stmt.setString (3, __report.varA);
stmt.setString (4, __report.varB);
stmt.setInt (5, __report.varC);
stmt.setString (6, __report.varD);
stmt.setString (7, __report.varE);
stmt.setString (8, __report.varF);
stmt.setTimestamp(9, reportTime);
stmt.setNull (10, occi::OCCITIMESTAMP);
stmt.setString 开发者_开发问答 (11, __report.varG);
stmt.setString (12, __report.varH);
stmt.setString (13, __report.varI);
stmt.setString (14, __report.varK);
stmt.setString (15, __report.varX);
stmt.setBinaryStreamMode(16, __report.payload.Size(), true);
stmt.executeUpdate();
occi::Stream* streamedData = stmt.getStream(16);
streamedData->writeLastBuffer(__report.payload.GetPtr(), __report.payload.Size());
stmt.closeStream(streamedData);
occi::Environment::terminateEnvironment(tempEnv);
return true;
}
The function below works perfectly unless the code above is executed and looks like this:
{
ora::Statement stmt(__cn);
string sql("BEGIN "
"Pckg.Sp_procB(:1, :2, :3, :4, :5, :6, :7, :8, :9, :10, :11); END;");
occi::Environment* tempEnv = occi::Environment::createEnvironment();
occi::Timestamp reportTime(tempEnv);
reportTime.fromText(__report.report_time, "yyyy-mm-dd HH24:mi:ss.ff");
stmt.setSQL(sql);
stmt.setString (1, "");
stmt.setString (2, "");
stmt.setString (3, __report.varA);
stmt.setString (4, __report.varB);
stmt.setInt (5, __report.varB);
stmt.setString (6, __report.varD);
stmt.setString (7, __report.varE);
stmt.setString (8, __report.varF);
stmt.setString (9, __report.varG);
stmt.setTimestamp(10, reportTime);
stmt.setNull (11, occi::OCCITIMESTAMP);
stmt.executeUpdate();
occi::Environment::terminateEnvironment(tempEnv);
return true;
}
I got the blob insert example from Oracle's documentation and can't see anything wrong with it. The second function also seems to be ok which got me thinking that Oracle's occi might have some kind of bug that corrupts memory. Anyone knows anything about this or has done anything similar?
精彩评论