Tom Lane wrote:
> "Joshua D. Drake" <[EMAIL PROTECTED]> writes:
> > Well if we are going to continue to support money (which I am against)
> > we should support the casting to numeric as that is by far a more
> > common implementation of money and we will have mixed environments.
> 
> So, you don't use MONEY, and you don't want to, but nonetheless you
> know better than the people who do use MONEY what they need.
> 
> Aside from the semantic-gap issue, there is the point that providing
> a cast might actually mask application errors.  I can well imagine
> cases where one of the reasons for using MONEY is *exactly* that it's
> not a plain number or easily convertible to one.

Right.  I am not thinking of an auto-cast but rather give people _some_
way to cast to/from MONEY, which is what the TODO says:

        * Allow MONEY to be cast to/from other numeric data types

Even when we have multiple currency designations I would think people
would need a way to cast.  I am trying to anticpate how MONEY will be
used.  You are right we don't have any field requests yet, but I am
expecting them.

I have added documentation on the issues of casting to/from MONEY; 
patch attached and applied.

-- 
  Bruce Momjian  <[EMAIL PROTECTED]>        http://momjian.us
  EnterpriseDB                             http://postgres.enterprisedb.com

  + If your life is a hard drive, Christ can be your backup. +
Index: doc/src/sgml/datatype.sgml
===================================================================
RCS file: /cvsroot/pgsql/doc/src/sgml/datatype.sgml,v
retrieving revision 1.217
diff -c -c -r1.217 datatype.sgml
*** doc/src/sgml/datatype.sgml	21 Nov 2007 04:01:37 -0000	1.217
--- doc/src/sgml/datatype.sgml	27 Nov 2007 05:45:13 -0000
***************
*** 842,847 ****
--- 842,855 ----
      floating-point literals, as well as <quote>typical</quote>
      currency formatting, such as <literal>'$1,000.00'</literal>.
      Output is generally in the latter form but depends on the locale.
+     Non-quoted numeric values can be converted to <type>money</type> by
+     casting the numeric value to <type>text</type> and then
+     <type>money</type>:
+ <programlisting>
+ SELECT 1234::text::money;
+ </programlisting>
+     There is no simple way of doing the reverse;  casting a <type>money</type> value to a
+     numeric type.
     </para>
  
     <para>
---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings

Reply via email to