Re: How to convert numbers into words in postgresql

From: Adrian Klaver <adrian(dot)klaver(at)gmail(dot)com>
To: Merlin Moncure <mmoncure(at)gmail(dot)com>
Cc: John R Pierce <pierce(at)hogranch(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: How to convert numbers into words in postgresql
Date: 2013-05-14 23:12:31
Message-ID: 5192C4DF.7080601@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 05/14/2013 03:27 PM, Merlin Moncure wrote:
> On Tue, May 14, 2013 at 5:24 PM, Adrian Klaver <adrian(dot)klaver(at)gmail(dot)com> wrote:

>> Seems to only work with money type.
>
> from the source:
> /* cash_words()
> * This converts a int4 as well but to a representation using words
> * Obviously way North American centric - sorry
> */
> Datum
> cash_words(PG_FUNCTION_ARGS)
> {

Well Pg 9.0 did not get that memo:)

test=> SELECT version();
version

----------------------------------------------------------------------------------------------------------------------------------
PostgreSQL 9.0.13 on i686-pc-linux-gnu, compiled by GCC gcc (SUSE
Linux) 4.7.1 20120723 [gcc-4_7-branch revision 189773], 32-bit
(1 row)

test=> SELECT cash_words(123);
ERROR: function cash_words(integer) does not exist
LINE 1: SELECT cash_words(123);
^
HINT: No function matches the given name and argument types. You might
need to add explicit type casts.

Though using text works:

test=> SELECT cash_words('123');
cash_words
-------------------------------------------------
One hundred twenty three dollars and zero cents

>
> so, it comes down to the money type is one of the more bizarre things
> left from postgres past and we try not to advertise too loudly I
> suppose.

Agreed.

>
> merlin
>

--
Adrian Klaver
adrian(dot)klaver(at)gmail(dot)com

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Oscar Calderon 2013-05-15 00:02:50 PostgreSQL TCL extension - Redhat 5
Previous Message Julian 2013-05-14 22:52:18 Re: How to convert numbers into words in postgresql