Topic: SQL*Plus and PL/SQL >> Oracle Function
|
Disclaimer: The purpose of all dbapool forums including OCP and Other Oracle Certification forums is to help each other with specific issues but not to share dump and copyrighted exam content, materials or intellectual property.
You may review the entire Oracle Certification Program Candidate Agreement online Here.
|
|
|
|
| Subhranil |
Posted: Apr 04, 2006 03:05:43 AM |
Total Post: 28
Joined: Jul, 2005
|
Hi!
Is there any function to convert number to the respective word.
i.e if I will fire the query "Select function_name(1000000000000) from dual" it will return me "One billion"?
Thanks in advance!
Subhranil Chakraborty
|
|
|
Srinivas |
| Posted: Apr 06, 2006 08:38:22 AM | |
|
Total Post: 7
Joined: Apr, 2006
|
function spell_number( p_number in number )
return varchar2
as
type myArray is table of varchar2(255);
l_str myArray := myArray( '',
' thousand ', ' million ',
' billion ', ' trillion ',
' quadrillion ', ' quintillion ',
' sextillion ', ' septillion ',
' octillion ', ' nonillion ',
' decillion ', ' undecillion ',
' duodecillion ' );
l_num varchar2(50) default trunc( p_number );
l_return varchar2(4000);
begin
for i in 1 .. l_str.count
loop
exit when l_num is null;
if ( substr(l_num, length(l_num)-2, 3) <> 0 )
then
l_return := to_char(
to_date(
substr(l_num, length(l_num)-2, 3),
'J' ),
'Jsp' ) || l_str(i) || l_return;
end if;
l_num := substr( l_num, 1, length(l_num)-3 );
end loop;
return l_return;
end;
/
Chill :)
|
|
|
|
|
Subhranil |
| Posted: Apr 07, 2006 12:07:22 AM | |
|
Total Post: 28
Joined: Jul, 2005
|
Thanks Surender
It is working fine.
Regards
Subhranil
|
|
|
|
|
Manu |
| Posted: May 20, 2006 07:44:11 AM | |
|
Total Post: 11
Joined: May, 2006
|
You can use this to find out amount in words upto 5373484.
SELECT TO_CHAR(TO_DATE(\'5000\',\'J\'),\'JSP\') FROM DUAL;
Output
=======
Five Thousand.
|
|
|
|
|
newuser |
| Posted: Feb 26, 2008 06:10:41 AM | |
|
Total Post: 6
Joined: Feb, 2008
|
hi,
can u pls explain working of this query
SELECT TO_CHAR(TO_DATE(\'5000\',\'J\'),\'JSP\') FROM DUAL
Thanks,
Nagaraj
|
|
|
|
|
| Time Zone: EDT |
Send this thread to your friend |
|
|
|
|
Forum Rules & Description
Who Can Read The Forum? Any registered user or guest
Who Can Post New Topics? Any registered user
Who Can Post Replies? Any registered user
|
| |
Get FREE Magazines
|
Top 10 Forum User
|
| Murtuja Khokhar | 843 |
| Mohammed Taj | 746 |
| positive fanatic | 483 |
| Jayanta Sur | 479 |
| Vigyan Kaushik | 386 |
| Gitesh Trivedi | 322 |
| Gopu Gopi | 268 |
| neeraj sharma | 252 |
| Ramesh Jois | 245 |
| Bishal Khetan | 207 |
|
|