CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
+ Reply to Thread
Results 1 to 5 of 5
  1. #1
    Join Date
    Mar 2012
    Posts
    7

    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.

  2. #2
    Join Date
    May 2004
    Location
    45,000FT Above Nevada
    Posts
    1,531

    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.

  3. #3
    Join Date
    Mar 2012
    Posts
    7

    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.

  4. #4
    Join Date
    Mar 2012
    Posts
    7

    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.

  5. #5
    Join Date
    May 2004
    Location
    45,000FT Above Nevada
    Posts
    1,531

    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.

+ Reply to Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts



HTML5 Development Center

Click Here to Expand Forum to Full Width