I am trying to call a stored procedure from C++ code using OCCI. The stored procedure has the following signature:
create or replace PROCEDURE "MYTESTPROC" ( param1 OUT NUMBER, param2 OUT int, param3 OUT smallint, param4 OUT int, param5 OUT RAW, param6 OUT int, param7 IN OUT CLOB )
The code which I'm using is the following:
#include <iostream>
#include <occi.h>
using namespace std;
using namespace oracle::occi;
int main(int argc, char *argv[])
{
std::string user="test";
std::string pass="test";
std::string db="//192.168.1.5/Test";
int len;
Environment *env = Environment::createEnvironment(Environment::DEFAULT);
Connection *con = env->createConnection(user, pass, db);
Statement *stmt = con->createStatement("BEGIN MYTESTPROC(:1, :2, :3, :4, :5, :6, :7); END;");
stmt->registerOutParam(1, OCCINUMBER);
stmt->registerOutParam(2, OCCIINT);
stmt->registerOutParam(3, OCCINUMBER);
stmt->registerOutParam(4, OCIINT);
stmt->registerOutParam(5, OCCIBYTES);
stmt->registerOutParam(6, OCCIINT);
stmt->registerOutParam(7, OCCICLOB);
ResultSet *rs = stmt->executeQuery();
Clob clob2 = stmt->getClob(7);
len = clob2.length();
printf("len=%d\n", len);
Stream *in = clob2.getStream(1, 0);
con->terminateStatement(stmt);
env->terminateConnection(con);
Environment::terminateEnvironment(env);
return 0;
}
The problem is that the length of the clob (len) is set to 0. The pointer to the stream object is not NULL and the clob is initialized and open.
Please advise if I am doing something wrong.
Thanks!