P
P
Pavel2422015-07-31 10:57:24
Oracle
Pavel242, 2015-07-31 10:57:24

When getting numeric values ​​via odbc in microsoft visual c++ via GetFieldValue, an exception occurs, how would you recommend treating it?

If you do not specify the third parameter in GetFieldValue as SQL_C_SLONG when getting numeric values ​​or the results of a function of type count, then the exception "Error in column 1. Numeric value out of range" is thrown. If only the return value is less than 100, then everything is fine. Database - ORACLE. It would not be desirable to explicitly prescribe the resulting type, is there any solution?
Here is a simple example to demonstrate

CDatabase base;
base.OpenEx(_T("DSN=db;UID=user;PWD=password"));

CRecordset rs(&base);
rs.Open(CRecordset::forwardOnly, _T("select 101 from dual"), CRecordset::readOnly);

CDBVariant var;
try {
   rs.GetFieldValue((short)0, var);
}
catch(CException *e) {
    char buffer[255];
    e->GetErrorMessage(buffer, 255);
}

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question