Re: [QUESTIONS] money * money?

From: "Thomas G(dot) Lockhart" <lockhart(at)alumni(dot)caltech(dot)edu>
To: Brett McCormick <brett(at)work(dot)chicken(dot)org>
Cc: Postgres Hackers List <hackers(at)postgresql(dot)org>
Subject: Re: [QUESTIONS] money * money?
Date: 1998-04-05 17:46:06
Message-ID: 3527C35E.A1F12A4F@alumni.caltech.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> The following query works:
> brett=> select '1'::money * 2;
> but this one doesn't:
> brett=> select sum('1'::money) * 2
> with the following error:
> ERROR: There is no operator '*' for types 'money' and 'money'
> bug?

Feature, until we fix it :)
I'm working on automatic type conversion for v6.4, and your specific
example already works in my preliminary code:

tgl=> select sum('$1.00'::money) * 2;
--------
$2.00
(1 row)

And even:

tgl=> select sum('$1.00'::money) * 2.5;
--------
$2.50
(1 row)

> Also, are there any plans to remove the dollar sign from the money
> type? Or are we just going to use integers with precision. How do I
> create a table with integers that only output the first two decimal
> places?

We don't yet have exact numerics with a scale other than zero (a
standard integer). We need to get an implementation with either a BCD
package, or 64-bit integers, or the GNU extended-precision math package,
or ?? to enable arbitrary range integers with scale. We also probably
need some work on the backend to pass along extended information for
these kinds of types (e.g. the precision and scale defined for a target
column).

- Tom

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 1998-04-05 19:57:00 Re: [HACKERS] Open 6.3.1 issues
Previous Message Thomas G. Lockhart 1998-04-05 17:06:18 Re: [HACKERS] Open 6.3.1 issues