Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: Handling Currency in Database.
Thomas Kellerer <NNGNVRDSJEBN_at_spammotel.com> wrote in message news:<30146nF2sc22sU1_at_uni-berlin.de>...
> On 17.11.2004 14:47 linevoltage_halogen wrote:
>
> > Greetings All, I was hoping that someone might be able to offer some
> > insight on how to handle currency both in a base table and within
> > PL/SQL. My goal is to ensure that no rounding errors are introduced
> > when moving these values around. I suspect that if I define an
> > attribute as number(14,4) that all rounding errors will be avoided
> > when doing arithmetic? Any help would be greatly appreciated.
> >
> > TFD
>
> If you absolutely want to avoid rounding errors, then store your values as
> integers (= NUMBER(22)) and adjust the number when displaying.
>
> Depending on the required accuracy you would then store your values as cents,
> 10th of a cent, 100th of a cent etc. and divide by the required factor when
> displaying the price.
>
> Regards
> Thomas
Thomas, first off thank you for your response. If you wouldn't mind humoring me a bit more it would be greatly appreciated. I am new to this concept of storing and handling currency and I am having a bit of a time trying to get my head around your statement that storing the numbers as an integer would be better. Can you provide me with a concrete example that would obviate your methods superiority over storing currency with some precision?
Thank You.
TFD Received on Thu Nov 18 2004 - 09:20:12 CST
![]() |
![]() |