Conversion of NUMBER to WORDS

Posted on 2001-09-10
Medium Priority
Last Modified: 2008-03-10
Hi there !!

I want to write a function or procedure which accepts a decimal number as its arguement and returns the same number translated into words.

The procedure should give me the following output for given inputs :

1) INPUT : 2300.34
   OUTPUT : Rupees Two Thousand Three Hundred and Paise Thirty Four Only.

2) INPUT : 1523420.25
   OUTPUT : Rupees Fifteen Lacs Twenty Three Thousand Four Hundred Twenty and Paise Twenty Five Only.

3) INPUT : 23455255.00
   OUTPUT : Rupees Two Crore Thirty Four Lacs Fifty Five Thousand Two Hundred Fifty Five and Paise Zero Only.

Here the maximum number I will input will be 99999999.99 and there will be only 2 decimal places. The number before the decimal point is RUPEES and the number after the decimal point is PAISE.

I have tried a lot but I am unable to get it. Please send me the PL/SQL for this procedure.

Question by:manish_saraswat
LVL 48

Expert Comment

ID: 6470367
Look at the following example and try to construct the solution:

1* select to_char( to_date(5373484,'J'),'Jsp') from dual
SQL> /

Five Million Three Hundred Seventy-Three Thousand Four Hundred Eighty-Four

This will work for numbers between 1 and 5,373,484...
You can take it a step further to support numbers -5,373,484 .. 5,373,484 by
select decode( sign( :N ), -1, 'Negative ', 0, 'Zero', NULL ) | |
decode( sign( abs(:N) ), +1, to_char( to_date( abs(:N),'J'),'Jsp') )
from dual
That covers the integer numbers.

FROM dual
That's the maximum

Try using the spelcheck.sql file found in chapter 5 of the book 'Oracle8 PL/SQL programming' by Scott Urman. The maximum no you can spell out is 10**10. I have sent the spelcheck.sql file by mail to you. Try using that.

Accepted Solution

s_lahiri earned 400 total points
ID: 6472507
Try this and this should give you the result you are looking for:

select 'Rupees ' ||
'J'),'JSP') || ' crore ') ||
'J'),'JSP') || ' lac ') ||
'J'),'JSP') || ' thousand ') ||
'J'),'JSP') || ' hundred ') ||
'J'),'JSP') || ' ') ||
'and Paise ' ||
'J'),'JSP') ) ||
' Only'
from dual

Cheers ..

Author Comment

ID: 6473421
Hi there !!!

schwertner's answer was too good and correct too but as I am in India, here the numbering system of MILLIONS is not valid. So I accept the answer of s_lahiri. Hey lahiri yor answer was too good and worked PERFECTLY !!! Thanx a lot and this made my report to work.

Have a GREAT time,

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

How to Unravel a Tricky Query Introduction If you browse through the Oracle zones or any of the other database-related zones you'll come across some complicated solutions and sometimes you'll just have to wonder how anyone came up with them.  …
This post first appeared at Oracleinaction  (http://oracleinaction.com/undo-and-redo-in-oracle/)by Anju Garg (Myself). I  will demonstrate that undo for DML’s is stored both in undo tablespace and online redo logs. Then, we will analyze the reaso…
This video shows syntax for various backup options while discussing how the different basic backup types work.  It explains how to take full backups, incremental level 0 backups, incremental level 1 backups in both differential and cumulative mode a…
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

597 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question