Thread: Function for adding Money type

Function for adding Money type

From
"David Durst"
Date:
Are there functions for adding and subtracting this type from itself?
Or is there a simple way to do it?




Re: Function for adding Money type

From
Josh Berkus
Date:
David,

> Are there functions for adding and subtracting this type from itself?
> Or is there a simple way to do it?

The MONEY type is depreciated, and should have been removed from the Postgres
source but was missed as an oversight.   Use NUMERIC instead.

--
-Josh BerkusAglio Database SolutionsSan Francisco



Re: Function for adding Money type

From
"David Durst"
Date:
> David,
>
>> Are there functions for adding and subtracting this type from itself?
>> Or is there a simple way to do it?
>
> The MONEY type is depreciated, and should have been removed from the
> Postgres  source but was missed as an oversight.   Use NUMERIC instead.
>
> --
> -Josh Berkus
>  Aglio Database Solutions
>  San Francisco
Already done, I found it in another doc.
Thanks though




Re: Function for adding Money type

From
"D'Arcy J.M. Cain"
Date:
On Friday 24 January 2003 19:17, Josh Berkus wrote:
> The MONEY type is depreciated, and should have been removed from the
> Postgres source but was missed as an oversight.   Use NUMERIC instead.

Note that not all of us agree.  I had to change all of our fields from MONEY 
to NUMERIC recently because of the lack of support for MONEY but I would 
prefer to see it improved instead.  Now that we have changed we find that we 
need to create a new table for balances driven by a trigger because 
calculating balances just went up in cost with that change.  The reason is 
simply that MONEY used nothing but integer arithmetic and NUMERIC has to do a 
lot more processing in code.

This year, my team is planning on improving the MONEY type.  Of course, we can 
always make it a user defined type if PostgreSQL doesn't want it.  We will at 
least put it into contrib.  However, if people think that it is useful and 
want to leave it in the main tree that's good too.  What we want to do is a) 
switch to a 64 bit integer from a 32 bit integer in order to hold amounts of 
any reasonabe size and b) allow it to be cast to and from more types.  
Perhaps we can also add the ability to specify the number of decimal places 
on output but I am not sure if that would affect the primary benefit of using 
it, speed.

-- 
D'Arcy J.M. Cain <darcy@{druid|vex}.net>   |  Democracy is three wolves
http://www.druid.net/darcy/                |  and a sheep voting on
+1 416 425 1212     (DoD#0082)    (eNTP)   |  what's for dinner.


Re: Function for adding Money type

From
Thomas Good
Date:
On Sun, 26 Jan 2003, D'Arcy J.M. Cain wrote:

> This year, my team is planning on improving the MONEY type.  Of course, we can
> always make it a user defined type if PostgreSQL doesn't want it.  We will at
> least put it into contrib.  However, if people think that it is useful and
> want to leave it in the main tree that's good too.  What we want to do is a)
> switch to a 64 bit integer from a 32 bit integer in order to hold amounts of
> any reasonabe size and b) allow it to be cast to and from more types.
> Perhaps we can also add the ability to specify the number of decimal places
> on output but I am not sure if that would affect the primary benefit of using
> it, speed.

Hey good news D'Arcy!  I prefer using MONEY as well.

-----------------------------------------------------------------------
Thomas Good                                  e-mail: tomg@sqlclinic.net
Programmer/Analyst                           phone:   (+1) 718.818.5528
Residential Services                         fax:     (+1) 718.818.5056
Behavioral Health Services, SVCMC-NY         mobile:  (+1) 917.282.7359
   --            Geistiges Eigentum ist Diebstahl!              --



Re: Function for adding Money type

From
Oliver Elphick
Date:
On Sun, 2003-01-26 at 13:53, D'Arcy J.M. Cain wrote:

> This year, my team is planning on improving the MONEY type.  Of course, we can 
> always make it a user defined type if PostgreSQL doesn't want it.  We will at 
> least put it into contrib.  However, if people think that it is useful and 
> want to leave it in the main tree that's good too.  What we want to do is a) 
> switch to a 64 bit integer from a 32 bit integer in order to hold amounts of 
> any reasonabe size and b) allow it to be cast to and from more types.  
> Perhaps we can also add the ability to specify the number of decimal places 
> on output but I am not sure if that would affect the primary benefit of using 
> it, speed.

A money type needs to specify what currency is held.  The current one
changes the currency with the locale, which makes nonsense of existing
data.

-- 
Oliver Elphick                                Oliver.Elphick@lfix.co.uk
Isle of Wight, UK                             http://www.lfix.co.uk/oliver
GPG: 1024D/3E1D0C1C: CA12 09E0 E8D5 8870 5839  932A 614D 4C34 3E1D 0C1C
========================================   "Wash me thoroughly from mine iniquity, and cleanse me      from my sin. For
Iacknowledge my transgressions; and      my sin is ever before me. Against thee, thee only,      have I sinned, and
donethis evil in thy sight..."                                  Psalms 51:2-4 
 



Re: Function for adding Money type

From
Bruce Momjian
Date:
Oliver Elphick wrote:
> On Sun, 2003-01-26 at 13:53, D'Arcy J.M. Cain wrote:
> 
> > This year, my team is planning on improving the MONEY type.  Of course, we can 
> > always make it a user defined type if PostgreSQL doesn't want it.  We will at 
> > least put it into contrib.  However, if people think that it is useful and 
> > want to leave it in the main tree that's good too.  What we want to do is a) 
> > switch to a 64 bit integer from a 32 bit integer in order to hold amounts of 
> > any reasonabe size and b) allow it to be cast to and from more types.  
> > Perhaps we can also add the ability to specify the number of decimal places 
> > on output but I am not sure if that would affect the primary benefit of using 
> > it, speed.
> 
> A money type needs to specify what currency is held.  The current one
> changes the currency with the locale, which makes nonsense of existing
> data.

Agreed.  We can default to locale but need a way of overriding that,
ideally with atttypmod at the column level.  I assume this will be done
for 7.4 (you said "this year")?

--  Bruce Momjian                        |  http://candle.pha.pa.us pgman@candle.pha.pa.us               |  (610)
359-1001+  If your life is a hard drive,     |  13 Roberts Road +  Christ can be your backup.        |  Newtown Square,
Pennsylvania19073