List:MySQL++« Previous MessageNext Message »
From:Warren Young Date:December 26 2007 10:11pm
Subject:Re: Troubles wit DECIMAL(12,4)
View as plain text  
Bart Verstraete wrote:
> 
> mysqlpp::longlong id = (mysqlpp::longlong)row["id"];

The casts aren't necessary.  Or if they are, it means the implicit 
conversion rules aren't working, which would be a bug.

> double total = (double)row["total"] //Throws an exception: Tried to 
> convert "6.3000" to a "d

In that case, many of the examples should be showing the same symptom, 
because they do essentially this same thing.  It works fine here on my 
main GCC/Linux development system.

So, try the examples.  If they fail there, I think the problem may be 
that your compiler isn't smart enough to create ColData::conv(double) 
and so is falling back to the default definition of conv() which only 
works for things that look sufficiently like integers.  We'll need to 
know your compiler and platform to be able to test any fix that may be 
required.

If the examples work but your program doesn't, you've got something very 
weird going on.

Once you sort all this out, consider using mysqlpp::sql_decimal instead 
of double.  They're typedef'd to the same thing, but may not be forever. 
  This type is a good candidate for a specialized replacement because 
DECIMAL is a fixed-point type, so double isn't the best match.  We 
really should have something in the mold of mysqlpp::tiny_int here.
Thread
Troubles wit DECIMAL(12,4)Bart Verstraete23 Dec
  • Re: Troubles wit DECIMAL(12,4)Warren Young26 Dec
    • Re: Troubles wit DECIMAL(12,4)Bart Verstraete4 Jan
      • Re: Troubles wit DECIMAL(12,4)Bart Verstraete4 Jan
        • RE: Troubles wit DECIMAL(12,4)Joel Fielder4 Jan
          • Re: Troubles wit DECIMAL(12,4)Bart Verstraete4 Jan
            • RE: Troubles wit DECIMAL(12,4)Joel Fielder4 Jan
              • Re: Troubles wit DECIMAL(12,4)Bart Verstraete4 Jan
        • Re: Troubles wit DECIMAL(12,4)Warren Young4 Jan
          • Re: Troubles wit DECIMAL(12,4)Bart Verstraete4 Jan
            • Re: Troubles wit DECIMAL(12,4)Warren Young4 Jan
              • Re: Troubles wit DECIMAL(12,4)Bart Verstraete5 Jan
                • Re: Troubles wit DECIMAL(12,4)Jonathan Wakely5 Jan
      • Re: Troubles wit DECIMAL(12,4)Warren Young4 Jan