|
-
March 3rd, 2012, 11:30 AM
#1
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.
-
March 3rd, 2012, 03:15 PM
#2
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)
Jim
ATP BE400 CE500 (C550B-SPW) CE560XL MU300 CFI CFII
"The speed of non working code is irrelevant"... Of course that is just my opinion, I could be wrong.
"Nothing in the world can take the place of persistence. Talent will not; nothing is more common than unsuccessful men with talent. Genius will not; unrewarded genius is almost a proverb. Education will not; the world is full of educated derelicts. Persistence and determination are omnipotent. The slogan 'press on' has solved and always will solve the problems of the human race."...Calvin Coolidge 30th President of the USA.
-
March 3rd, 2012, 07:16 PM
#3
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.
-
March 4th, 2012, 11:39 AM
#4
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.
-
March 4th, 2012, 07:04 PM
#5
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 );
Jim
ATP BE400 CE500 (C550B-SPW) CE560XL MU300 CFI CFII
"The speed of non working code is irrelevant"... Of course that is just my opinion, I could be wrong.
"Nothing in the world can take the place of persistence. Talent will not; nothing is more common than unsuccessful men with talent. Genius will not; unrewarded genius is almost a proverb. Education will not; the world is full of educated derelicts. Persistence and determination are omnipotent. The slogan 'press on' has solved and always will solve the problems of the human race."...Calvin Coolidge 30th President of the USA.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|