pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedcalulating with money type impossible ?
2+ messages / 2 participants
[nested] [flat]
* calulating with money type impossible ?
@ 1999-11-05 21:58 De Moudt Walter <wdemoudt@planetinternet.be>
1999-11-06 14:48 ` Re: [SQL] calulating with money type impossible ? Peter Eisentraut <peter_e@gmx.net>
0 siblings, 1 reply; 2+ messages in thread
From: De Moudt Walter @ 1999-11-05 21:58 UTC (permalink / raw)
To: psql-general <pgsql-general@postgresql.org>; pgsql-sql
Hi,
This is kind of a repost, because i didn't get any answers on it last
time :-(
Trying to find a way to calculate with the money-type. The kind of :
select (sales_price/transport_costs) as trans_rate from account_details;
to get the ratio of to amounts of money. The result should be a float!
Well, it doesn't seem possible.
In pg_proc table i found 2 procedures possibly usable for money
conversion:
cash_out(): takes one money argument, delivers a int4
cash_in() : takes one argument (don't know what kind) and delivers a
money-type.
Here's what i got with it :
bookbiz=> select cash_in(20);
pqReadData() -- backend closed the channel unexpectedly.
This probably means the backend terminated abnormally
before or while processing the request.
We have lost the connection to the backend, so further processing is
impossible. Terminating.
\* so i reconnect \*
[walter@localhost walter]$ psql bookbiz
bookbiz=> select cash_out('$25.00');
cash_out
---------
136509096
(1 row)
bookbiz=> select cash_out('$25.00');
cash_out
---------
136508128
(1 row)
bookbiz=>
(2 different results for the same argument)
So cash_in kicks me out, an cash_out just delivers nonsens.
I'm using postgresql server version 6.5.2.1
and client 6.5.1.2, RPM-versions on RedHat 6.0.
Has any-one done better with money (on postgres) ?
Please let me know, if it isn't possible as well.. then i just
change my money-fields to floats
Thanks
De Moudt Walter.
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: [SQL] calulating with money type impossible ?
1999-11-05 21:58 calulating with money type impossible ? De Moudt Walter <wdemoudt@planetinternet.be>
@ 1999-11-06 14:48 ` Peter Eisentraut <peter_e@gmx.net>
0 siblings, 0 replies; 2+ messages in thread
From: Peter Eisentraut @ 1999-11-06 14:48 UTC (permalink / raw)
To: De Moudt Walter <wdemoudt@planetinternet.be>; +Cc: psql-general <pgsql-general@postgresql.org>; pgsql-sql
The money type is deprecated in favour of the NUMERIC(9,2) (or whatever)
type. There indeed aren't a lot of functions and operators for money, and
no one is going to implement them now. In fact, type money might disappear
soon!
-Peter
On 1999-11-05, De Moudt Walter mentioned:
> Hi,
>
> This is kind of a repost, because i didn't get any answers on it last
> time :-(
>
> Trying to find a way to calculate with the money-type. The kind of :
>
> select (sales_price/transport_costs) as trans_rate from account_details;
>
> to get the ratio of to amounts of money. The result should be a float!
>
> Well, it doesn't seem possible.
> In pg_proc table i found 2 procedures possibly usable for money
> conversion:
> cash_out(): takes one money argument, delivers a int4
> cash_in() : takes one argument (don't know what kind) and delivers a
> money-type.
>
> Here's what i got with it :
>
> bookbiz=> select cash_in(20);
> pqReadData() -- backend closed the channel unexpectedly.
> This probably means the backend terminated abnormally
> before or while processing the request.
> We have lost the connection to the backend, so further processing is
> impossible. Terminating.
> \* so i reconnect \*
> [walter@localhost walter]$ psql bookbiz
>
> bookbiz=> select cash_out('$25.00');
> cash_out
> ---------
> 136509096
> (1 row)
> bookbiz=> select cash_out('$25.00');
> cash_out
> ---------
> 136508128
> (1 row)
> bookbiz=>
> (2 different results for the same argument)
> So cash_in kicks me out, an cash_out just delivers nonsens.
>
> I'm using postgresql server version 6.5.2.1
> and client 6.5.1.2, RPM-versions on RedHat 6.0.
>
> Has any-one done better with money (on postgres) ?
> Please let me know, if it isn't possible as well.. then i just
> change my money-fields to floats
>
> Thanks
>
> De Moudt Walter.
>
> ************
>
>
--
Peter Eisentraut Sernanders vaeg 10:115
peter_e@gmx.net 75262 Uppsala
http://yi.org/peter-e/ Sweden
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~1999-11-06 14:48 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
1999-11-05 21:58 calulating with money type impossible ? De Moudt Walter <wdemoudt@planetinternet.be>
1999-11-06 14:48 ` Peter Eisentraut <peter_e@gmx.net>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox