Thread: money type depreciated?

money type depreciated?

From
"Karen Hill"
Date:
I read in the documentation that the money type is depreciated.  It
says to use the  to_char function and NUMERIC/decimal instead.  Why was
the money type depreciated when it was so useful?  How would be the
best way to use to_char and numeric to replace that type since I don't
want to be using a depreciated data type.

regards,


Re: money type depreciated?

From
Roman Neuhauser
Date:
# karen_hill22@yahoo.com / 2006-08-01 10:18:45 -0700:
> I read in the documentation that the money type is depreciated.  It
> says to use the  to_char function and NUMERIC/decimal instead.  Why was
> the money type depreciated when it was so useful?  How would be the
> best way to use to_char and numeric to replace that type since I don't
> want to be using a depreciated data type.

    Use a custom type; IIRC Martijn van Oosterhout has something.

--
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE.             http://bash.org/?255991

Re: money type depreciated?

From
Martijn van Oosterhout
Date:
On Tue, Aug 01, 2006 at 10:37:35PM +0000, Roman Neuhauser wrote:
> # karen_hill22@yahoo.com / 2006-08-01 10:18:45 -0700:
> > I read in the documentation that the money type is depreciated.  It
> > says to use the  to_char function and NUMERIC/decimal instead.  Why was
> > the money type depreciated when it was so useful?  How would be the
> > best way to use to_char and numeric to replace that type since I don't
> > want to be using a depreciated data type.
>
>     Use a custom type; IIRC Martijn van Oosterhout has something.

Indeed, I wrote a module called taggedtypes that provided a way to
create custom types based on a base type and a set of tags. One of the
uses is to take a numeric base type and have currency names as the
tags.

The end result is that you have a currency type that works like a
numeric, but will complain if you try to add values of different
currencies. Ofcourse the infrastructure is there to allow you to do
automatic conversion, and such things.

Anyway, check it out on the website. It's a bit terse, but it might
suit your needs. There's an example included in the tarball.

http://svana.org/kleptog/pgsql/taggedtypes.html

Have a nice day,
--
Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
> From each according to his ability. To each according to his ability to litigate.

Attachment