Conversion of int values to numerals in Postgresql?

I would like to know if there is a built-in way to convert integer values into numerals in PostgreSQL?

As an example, is it possible to convert the integer 10 into the string TEN.

Thank You.


There's nothing built-in. For this sort of thing your best bet will be to make use of PostgreSQL's pluggable procedural languages. Use PL/Perl or PL/Python with a suitable Perl or Python library to do the job.

In this case I'd probably use PL/Perl with Lingua::EN::Numbers.

use Lingua::EN::Numbers qw(num2en);
return num2en($_[0]);
$$ LANGUAGE plperlu;

You'll need to install Lingua::EN::Numbers into the Perl being used by PostgreSQL using CPAN or system packages first. In my case (Fedora 19) this was a simple yum install perl-Lingua-EN-Numbers.noarch, then I could:

regress=> SELECT num2en(10);
(1 row)

regress=# SELECT num2en(NUMERIC '142.5');
 one hundred and forty-two point five
(1 row)

By default the function is accessible by normal users so you don't have to issue any extra GRANTs.

Try this query:

SELECT split_part (cash_words (10::VARCHAR::MONEY), 'dollar', 1);

It's a internal function of PostgreSQL.

Need Your Help

Malloc and structs in C are giving me errors (following a tutorial)?

c++ c visual-studio-2010 struct malloc

So I'm following a tutorial on C and I'm stuck at structs since they use the malloc function and that function doesn't seem to go well with my compiler (Visual Studio C++ 10.0). So I followed the

Unchecking of checkbox should remove appended html but

javascript jquery html html-lists

quick question, how to fix js code to remove text content from ul.results after checkbox has been unchecked. Strangely enough if the text is all simple letters or numbers the text is removed upon