Skip to content

Commit a0a9c5b

Browse files
committed
Add example of MONEY casting to numeric if locale is known.
1 parent 7888b52 commit a0a9c5b

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

doc/src/sgml/datatype.sgml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- $PostgreSQL: pgsql/doc/src/sgml/datatype.sgml,v 1.219 2007/11/27 06:05:57 momjian Exp $ -->
1+
<!-- $PostgreSQL: pgsql/doc/src/sgml/datatype.sgml,v 1.220 2007/11/27 16:46:36 momjian Exp $ -->
22

33
<chapter id="datatype">
44
<title id="datatype-title">Data Types</title>
@@ -848,8 +848,14 @@ ALTER SEQUENCE <replaceable class="parameter">tablename</replaceable>_<replaceab
848848
<programlisting>
849849
SELECT 1234::text::money;
850850
</programlisting>
851-
There is no simple way of doing the reverse using a locale-neutral
852-
method, namely casting a <type>money</type> value to a numeric type.
851+
There is no simple way of doing the reverse in a locale-independent
852+
manner, namely casting a <type>money</type> value to a numeric type.
853+
If you know the currency symbol and thousands separator you can use
854+
<function>regexp_replace()</>:
855+
<programlisting>
856+
SELECT regexp_replace('52093.89'::money::text, '[$,]', '', 'g')::numeric;
857+
</programlisting>
858+
853859
</para>
854860

855861
<para>

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy