2

I have to read a column of VARCHAR2 type from Oracle table in my CPP code. When I tried to get the VARCHAR2 as a string using getString() of OCCI call, the code fails.

In the below code, I am concerned in getting table column COST_VALUE of VARCHAR2<50>

Code:

string sqlStmt = "SELECT \”REJECTED COST\”, APPROVED_COST, COST_VALUE FROM COST_TABLE where PART_NUM= 'PN4879-1'";
            stmt = conn->createStatement(sqlStmt);
            ResultSet *rset = stmt->executeQuery();
            double dRejCost = 0;
            double dAppCost = 0;
            if(rset->next())
            {
             dRejCost = rset->getNumber(1);
             dAppCost = rset->getNumber(2);
             string strCost = rset->getString(3); 
            }
            stmt->closeResultSet(rset);
            conn->terminateStatement(stmt);

Error:

When I debugged I was able to see the value (from COST_TABLE column) being fetched in the string. But after the line (string strCost = rset->getString(3);) is executed, the application failed without any exception.

Please help with your expertise.

Jon Heller
  • 34,999
  • 6
  • 74
  • 132
Vijay
  • 55
  • 1
  • 5

0 Answers0