获取Clob对象的大小

时间:2017-11-21 08:43:46

标签: c++ occi

我试图使用OCCI从C ++代码调用存储过程。 存储过程具有以下签名:

创建或替换PROCEDURE" MYTESTPROC" (    param1 OUT NUMBER,    param2 OUT int,    param3 OUT smallint,    param4 OUT int,    param5 OUT RAW,    param6 OUT int,    param7 IN OUT CLOB )

我使用的代码如下:

#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;
}

问题是clob(len)的长度设置为0。 指向流对象的指针不是NULL,并且clob已初始化并打开。

请告知我是否做错了。

谢谢!

0 个答案:

没有答案