Subject Re: [firebird-support] About numeric data type to store Currency
Author Hannes Streicher
Hello,

> my probleme :

> i want to store currency in my database in Euro with 5 digit
> precision (ie i mean user can fill max of 5 digits precision for their currency).
> i store also in separate field the rate for CurrToEuro and EuroToCurr

why? store euro and original amount , saves you a lot of
conversion and rounding errors

> so when a user fill currency data in Rouble (for exemple), i
> convert it to Euro using RubToEuro field and store it in the
> database. When the user want to see his data back, i convert it back to Rub using the field EuroToRub


> now, i must choose the datatype for
> 1/ the currency field
> 2/ the CurrToEuro and EuroToCurr field

> i thing that max value than numeric can accept is NUMERIC(18,18)?
> but it's mean that i can store number like
> 123456789012345678.123456789012345678 in the field or only number
> like 0.123456789012345678 or 123456789012345678 ?

the field is total length and fractions
so 15.5 is 1234567890.12345

when the euro was introduced the official exchangerate was with
5 decimals

> For now i store currency in the database in
> NUMERIC(15,5)
> and the CurrToEuro and EuroToCurr in NUMERIC(12,6)
> the precision in both is clearly to little ! but i don't know what
> datatype to choose for best accurate

--
Mit freundlichen GrĂ¼ssen
Hannes Streicher mailto:HStreicher@...