Wrong return from GetFieldValue() with decimal field
Hi there,
I'm using MFC CRecordset to retrieve data from a Oracle Database 10g.
All is good except if a data type in database is NUMBER(x, y).
I looked into m_nSQLType of CODBCFieldInfo struct and it's correct, returning 3 (SQL_DECIMAL).
So, the function GetFieldValue(LPCTSTR lpszName, CDBVariant& varValue) returns a CDBVariant with wrong data type. He throws it as String instead of double.
I tried it with NUMBER (without precision) and it worked fine, but i need that precision.
Please, any help?
Kind Regards,
Warvimo.
Re: Wrong return from GetFieldValue() with decimal field
have you tried using SQL_C_DOUBLE as the third param in the function call ???
GetFieldValue(lpszName, varValue, SQL_C_DOUBLE)
Re: Wrong return from GetFieldValue() with decimal field
Hey,
No, i didn't tried this yet.
But is it required? I mean, force a cast to double.
I will test it and reply.
Thanks for answering.
Re: Wrong return from GetFieldValue() with decimal field
Hey Vanaj!
It worked!
Thanks so much.
I found out in sql defines DECIMAL, NUMERIC and VARCHAR is treated similarly...weird.
Thanks again,
Warvimo.
Re: Wrong return from GetFieldValue() with decimal field
Glad to help...sometimes you need to force values to what you need and not use the default and assume it will be correct...
Code:
void GetFieldValue( LPCTSTR lpszName, CDBVariant& varValue, short nFieldType = DEFAULT_FIELD_TYPE );