Received: from newbrussel.planetinternet.be (newbrussel.planetinternet.be [194.119.232.19]) by hub.org (8.9.3/8.9.3) with ESMTP id QAA09658; Fri, 5 Nov 1999 16:54:23 -0500 (EST) (envelope-from wdemoudt@planetinternet.be) Received: from planetinternet.be (u195-95-25-117.pop-antwerpen3.planetinternet.be [195.95.25.117]) by newbrussel.planetinternet.be (8.9.3/8.9.3) with ESMTP id WAA08202; Fri, 5 Nov 1999 22:49:36 +0100 (MET) Message-ID: <382352FB.D6779588@planetinternet.be> Date: Fri, 05 Nov 1999 22:58:19 +0100 From: De Moudt Walter X-Mailer: Mozilla 4.51 [en] (Win95; I) X-Accept-Language: en MIME-Version: 1.0 To: psql-general , pgsql-sql Subject: calulating with money type impossible ? Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit 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.