When I divide a money value by another money value, I get an error message, as 
follows:

***************************
psql (8.4.1)
Type "help" for help.

postgres=# select version();
                                                               version          
                                                      
--------------------------------------------------------------------------------------------------------------------------------------
 PostgreSQL 8.4.1 on i386-apple-darwin9.8.0, compiled by GCC 
i686-apple-darwin9-gcc-4.0.1 (GCC) 4.0.1 (Apple Inc. build 5490), 32-bit
(1 row)

postgres=# select '$2'::money / '$1'::money;
ERROR:  operator does not exist: money / money
LINE 1: select '$2'::money / '$1'::money;
                           ^
HINT:  No operator matches the given name and argument type(s). You might need 
to add explicit type casts.
***************************

I expected to get a result of 2 or 2.0 in some numeric type (maybe double 
precision). The result should be a pure number because the units (dollars, in 
this case) cancel out.

The ability to divide money by money would be useful for finding what percent 
one money value is of another. That is what I was wanting to use it for—finding 
out what percentage of a customer's original balance has been paid off.

It would also provide a better way to convert money into numeric types than the 
regular expression in the documentation. You could just divide the money amount 
by '1'::money.

Andy Balholm
(509) 276-2065
a...@balholm.com


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs

Reply via email to