oracle occi getString给出_BLOCK_TYPE_IS_VALID(pHead-> nBlockUse)

时间:2011-01-04 10:24:47

标签: c++ oracle

我正在尝试从OCCI Oracle查询中getString进行ResultSet,但我始终得到_BLOCK_TYPE_IS_VALID(pHead->nBlockUse)断言。我的项目是多线程调试,我试图将其设置为单线程调试,正如我在网上发现的建议,但这没有任何区别。

我有点不知道是什么导致了这个断言的发生。有人可以帮忙吗?

似乎我只使用getString()函数,而不是任何其他函数。

    oracle::occi::Environment* environment;
    oracle::occi::Connection* con;
    oracle::occi::Statement* stmt;
    oracle::occi::ResultSet* res;


        try{
         environment = oracle::occi::Environment::createEnvironment(oracle::occi::Environment::DEFAULT);
         con = environment->createConnection("db", "pssw", "DATABASE");     

        std::cout << "created connection" << std::endl;

        std::stringstream query;

        query << "SELECT MOD_KEY, MOD_SCRIPTLANGUAGE, MOD_SOURCE, MOD_CODE, MOD_STYLE, MOD_TYPE ";
        query << "FROM DB.MEDICAL_OBS_DEF ";
        query << "WHERE MOD_KEY = 735";

         stmt = con->createStatement(query.str());
         res = stmt->executeQuery();

         res->setMaxColumnSize(3,100);

         std::cout << "executed query" << std::endl;
         std::string mystring;
         while (res->next())
         {

             /*mystring = */res->getString(3);  ///_BLOCK_TYPE_IS_VALID(pHead->nBlockUse) Assert!
         }
         std::cout << "printed resultset" << std::endl;

         stmt->closeResultSet(res);
         con->terminateStatement(stmt);
        environment->terminateConnection(con);

     }catch(oracle::occi::SQLException &e){
         std::cout<<e.what();
    }

3 个答案:

答案 0 :(得分:2)

您是否已链接到Oracle DLL的调试版本(oraocci11d.liboraocci11d.dll)?

您的程序似乎使用Visual Studio的内存调试选项,而您使用的Oracle DLL则没有。因此发生错误是因为运行时库认为存在内存分配/释放问题。

答案 1 :(得分:2)

您使用的是哪种编译器?

请务必下载正确的occi版本 http://www.oracle.com/technetwork/database/occidownloads-083553.html

您必须使用DLL运行时:

  • DLL多线程调试(/ MDd),用于调试oraocci11d.lib和oraocci11d.dll
  • DLL多线程(/ MD)与oraocci11.lib和oraocci11.dll一起发布

答案 2 :(得分:1)

如果你使用UTF8字符集的数据库 尝试使用以下 环境*环境=环境:: createEnvironment(“AL32UTF8”,“UTF8”);