I am trying to execute a SQL query through OCCI calls in my CPP program.
I want to read 2 columns out of those one column name has a space in between. I tried enclosing the column name between ' '
, " "
, [ ]
and nothing helped. Can experts suggest me on answering this.
Below is my code: ....
string sqlStmt = "SELECT 'REJECTED COST', APPROVED_COST 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);
}
stmt->closeResultSet(rset);
conn->terminateStatement(stmt);
Error/Exception:
The error I get @ dRejCost = rset->getNumber(1);:
ORA-01722: invalid number
PS: The ORACLE table has the many columns where "REJECTED COST" column header is named with a space. I don't have the privilege to ask the DB team to change the DB table name though.
Thanks in advance.