Subject | Re: [firebird-support] Save decimal data type |
---|---|
Author | Francisco José Scheffer |
Post date | 2013-05-29T12:35:42Z |
thanks Ann;
Here is some code;
Declaration
Dim MyAmount as Double /* Double - 64 bit floating-point number */
Dim SQLString as String
MyAmount = 25.80
SQLString = "INSERT INTO MyTable(CANT) VALUES(MyAmount)"
In Firebird, the field CANT is: (I've tried Numeric, Decimal and FLOAT also)
With Decimal was 18,4
Numeric was 12,2
When Firebird save the data, it does as 2580, not 25.80;
Is it perhaps a problem on my Windows regional settings?
thanks for help!!
Francisco José Scheffer
________________________________
De: Ann Harrison <aharrison@...>
Para: firebird-support@yahoogroups.com
Enviado: martes, 28 de mayo de 2013 17:36
Asunto: Re: [firebird-support] Save decimal data type
Here is some code;
Declaration
Dim MyAmount as Double /* Double - 64 bit floating-point number */
Dim SQLString as String
MyAmount = 25.80
SQLString = "INSERT INTO MyTable(CANT) VALUES(MyAmount)"
In Firebird, the field CANT is: (I've tried Numeric, Decimal and FLOAT also)
With Decimal was 18,4
Numeric was 12,2
When Firebird save the data, it does as 2580, not 25.80;
Is it perhaps a problem on my Windows regional settings?
thanks for help!!
Francisco José Scheffer
________________________________
De: Ann Harrison <aharrison@...>
Para: firebird-support@yahoogroups.com
Enviado: martes, 28 de mayo de 2013 17:36
Asunto: Re: [firebird-support] Save decimal data type
On Tue, May 28, 2013 at 10:26 AM, franchessko <scheffer74@...> wrote:
> Hi, I'm a new firebird user. I joined here to ask for help.
> I develop in DotNet Technologies, and I have this problem:
>
>
> And the problem is:
> -------------------
> When I send a Query with a decimal data type like '25.80' -without quotes-
> the data is saved in firebird like this 2580,0000
> (the database field was created as Decimal 18,4)
>
Without seeing the actual queries you used, I'm guessing about why you see
what you see, but I can tell you what Firebird is doing. When you store
25.80 in a column that's defined as decimal 18,4, Firebird stores the
value as in integer, which in this case would be 258000 (two hundred fifty
eight thousand). The scale is part of the field definition. Firebird uses
the scale when doing comparisons, so 258000 scale 4 is more than 2570000
scale 5 and less than 260 scale 1. All that is fine, internally.
However, the SQL numeric and decimal types are based on data types used in
COBOL. Those data types are not generally supported in more modern
languages. When you retrieve a decimal or numeric value with a non-zero
scale, you should probably ask for it as a floating point number or a
string. You'll get better information from the Firebird .NET driver list
on exactly how to push decimal and numeric values through that interface.
> I tried sending the same number, but with the comma '25,80' but firebird
> says: "Dynamic SQL Error. SQL Error code = -804. Count of read-write
> columns does not equal count of values"
>
Firebird does not use the locale to choose the separator between the
integral and decimal portions of a number, so it's reading 25,80 as two
values 25 and 80.
Good luck,
Ann
[Non-text portions of this message have been removed]