Commit a0a9c5bc authored by Bruce Momjian's avatar Bruce Momjian

Add example of MONEY casting to numeric if locale is known.

parent 7888b520
<!-- $PostgreSQL: pgsql/doc/src/sgml/datatype.sgml,v 1.219 2007/11/27 06:05:57 momjian Exp $ --> <!-- $PostgreSQL: pgsql/doc/src/sgml/datatype.sgml,v 1.220 2007/11/27 16:46:36 momjian Exp $ -->
<chapter id="datatype"> <chapter id="datatype">
<title id="datatype-title">Data Types</title> <title id="datatype-title">Data Types</title>
...@@ -848,8 +848,14 @@ ALTER SEQUENCE <replaceable class="parameter">tablename</replaceable>_<replaceab ...@@ -848,8 +848,14 @@ ALTER SEQUENCE <replaceable class="parameter">tablename</replaceable>_<replaceab
<programlisting> <programlisting>
SELECT 1234::text::money; SELECT 1234::text::money;
</programlisting> </programlisting>
There is no simple way of doing the reverse using a locale-neutral There is no simple way of doing the reverse in a locale-independent
method, namely casting a <type>money</type> value to a numeric type. manner, namely casting a <type>money</type> value to a numeric type.
If you know the currency symbol and thousands separator you can use
<function>regexp_replace()</>:
<programlisting>
SELECT regexp_replace('52093.89'::money::text, '[$,]', '', 'g')::numeric;
</programlisting>
</para> </para>
<para> <para>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment