Bugs item #1853793, was opened at 2007-12-19 12:24
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=462816&aid=1853793&group_id=51305

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: E.Bevz (bevz)
Assigned to: Nobody/Anonymous (nobody)
Summary: Databaselayer: Firebird decimal types

Initial Comment:
When I read decimal numbers (for example, numeric(5,2)) from table, 
FirebirdResultSetMetadata returns field type as LONG and FirebirdResultSet 
returns wrong value of field.

Interbase docs:
"When a DECIMAL or NUMERIC value is stored as a SMALLINT, INTEGER, or 64-bit 
integer, the
value is stored as a whole number. During retrieval in DSQL, the sqlscale field 
of the
XSQLVAR is set to a negative number that indicates the factor of 10 by which 
the whole
number (returned in sqldata), must be divided in order to produce the correct 
NUMERIC
or DECIMAL value with its fractional part..."

Fix:
FirebirdResultSetMetadata.cpp:
FirebirdResultSetMetaData::GetColumnType()
{
...
      case SQL_LONG:
        if(pVar->sqlscale == 0)
            returnType = COLUMN_INTEGER;
        else
            returnType = COLUMN_DOUBLE;
        break;
...
}
FirebirdResultSet.cpp:
FirebirdResultSet::GetResultDouble()
{
...
    else if (nType == SQL_LONG)
    {
                  dblReturn = *(long *) (pVar->sqldata);
                  for(int i = 0; i < -pVar->sqlscale; dblReturn /= 10, i++);
    }
 and may be for some other sql types (int64, short...)
...
}

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=462816&aid=1853793&group_id=51305

-------------------------------------------------------------------------
SF.Net email is sponsored by:
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services
for just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
wxCode-users mailing list
wxCode-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wxcode-users

Reply via email to