Problem solve Get help with specific problems with your technologies, process and projects.

# Indian money to character conversion

## A script that converts numbers in the form of Indian money (rupees, paises, etc) into characters.

This solution is designed to convert numbers into words: for example, 100 to One Hundred. Since I am from India,...

this example uses rupees (for dollars), paises (for cents), lacs (10 lac=one milion), and so on, so you'll need to modify it to fit your needs. Here is the code for Oracle:

```*/

create or replace package num_to_word is
function to_num(num number) return char;
end;
/
create or replace package body num_to_word is

function num_to_char1 (num number) return char is
a number;
var_return  varchar(100);
begin
if num=1 then
return 'One';
elsif num=2 then
return 'Two';
elsif num=3 then
return 'Three';
elsif num=4 then
return 'Four';
elsif num=5 then
return 'Five';
elsif num=6 then
return 'Six';
elsif num=7 then
return 'Seven';
elsif num=8 then
return 'Eight';
elsif num=9 then
return 'Nine';
elsif num =0 then
return null;
end if;
end;

function num_to_char2 (num number) return char is
a number;
var_return  varchar(100);
begin
if  num=20 then
return ' Twenty';
elsif num=30 then
return ' Thirty';
elsif num=40 then
return ' Fourty';
elsif num=50 then
return ' Fifty';
elsif num=60 then
return ' Sixty';
elsif num=70 then
return ' Seventy';
elsif num=80 then
return ' Eighty';
elsif num=90 then
return ' Ninety';
else
return null;
end if;
end;

function num_to_char3 (num number) return char is
a number;
var_return  varchar(100);
begin
if  num=11 then
return 'Eleven';
elsif num=12 then
return 'Twelve';
elsif num=13 then
return 'Thirteen';
elsif num=14 then
return 'Fourteen';
elsif num=15 then
return 'Fifteen';
elsif num=16 then
return 'Sixteen';
elsif num=17 then
return 'Seventeen';
elsif num=18 then
return 'Eighteen';
elsif num =19 then
return 'Nineteen';
else return null;
end if;
end;

function to_num(num number) return char is
a number;
var_return   varchar(500);
num1   number:=num;
var_remain1   number;
begin

a:=length(num1);
if a=6 or a=7 then
var_remain1:=(trunc(num1/100000));
a:=length(var_remain1);
if a=2 then
if var_remain1=10 then
var_return:=var_return||' Ten ';
elsif var_remain1 between 11 and 19 then
var_return:=var_return||' '|| num_to_char3(var_remain1);
else
for i in 2..9 loop
var_return:=var_return|| num_to_char2(trunc(var_remain1,-1));
var_remain1:=mod(var_remain1,10);
end loop;
end if;
end if;
a:=length(var_remain1);
if a=1 then
var_return:=var_return||' '|| num_to_char1(var_remain1);
end if;
var_return:=var_return||' Lac ';
num1:=mod(num1,100000);
end if;

a:=length(num1);
if a =5 or a=4 then
var_remain1:=(trunc(num1/1000));
a:=length(var_remain1);
if a=2 then
if var_remain1=10 then
var_return:=var_return||' Ten ';
elsif var_remain1 between 11 and 19 then
var_return:=var_return||' '|| num_to_char3(var_remain1);
else
for i in 2..9 loop
var_return:=var_return|| num_to_char2(trunc(var_remain1,-1));
var_remain1:=mod(var_remain1,10);
end loop;
end if;
end if;

a:=length(var_remain1);
if a=1 then
var_return:=var_return||' '|| num_to_char1(var_remain1);
end if;
var_return:=var_return||' Thousand ';
num1:=mod(num1,1000);
end if;

a:=length(num1);
if a =3 then
for i in 1..9 loop
if trunc(num1/100)=i then
var_return:=var_return|| num_to_char1(i)||' Hundered';
num1:=mod(num1,100);
end if;
end loop;
end if;

a:=length(num1);
if a=2 then
if num1=10 then
var_return:=var_return||' Ten';
elsif num1 between 11 and 19 then
var_return:=var_return||' '|| num_to_char3(num1);
else
for i in 2..9 loop
var_return:=var_return|| num_to_char2(trunc(num1,-1));
num1:=mod(num1,10);
end loop;
end if;
end if;

a:=length(num1);
if a=1 then
var_return:=var_return||' '|| num_to_char1(num1);
end if;
return var_return;
end;

end ;
/
```

• The Best Oracle Web Links: tips, tutorials, scripts, and more.
• Have an Oracle tip to offer your fellow DBA's and developers? The best tips submitted will receive a cool prize--submit your tip today!
• Check out our Ask the Experts feature: Our SQL, database design, Oracle, SQL Server, DB2, metadata, and data warehousing gurus are waiting to answer your toughest questions.

This was last published in November 2001

#### Start the conversation

Send me notifications when other members comment.

## SearchDataManagement

• ### Hortonworks cloud options grow via Google, Microsoft, IBM

Hortonworks now supports Google Cloud Storage and has also broadened cloud deals with Microsoft and IBM, aiming to increase cloud...

• ### Evolving data integration strategies target new analytics needs

Most companies don't have a shortage of data, but it's often stored in siloed systems or inconsistent formats -- problems that ...

• ### What goes into a customer analytics data integration framework

Customer data integration is a minefield for IT teams to navigate. But incorporating a set of core technical functions into an ...

• ### Data-driven strategy grooms dog care franchise for growth

Camp Bow Wow is growing its day care and boarding business for dogs with the help of a data-driven approach that's powered by a ...

• ### Tableau acquisition of MIT AI startup aims at smarter BI software

Tableau acquires AI startup Empirical Systems in a plan to provide users with automated data modeling capabilities and enable ...

• ### Choosing the right data discovery platform for the enterprise

Obviously, cost and scalability factor into data discovery platform buying decisions, but other features, like visualizations and...

## SearchSAP

• ### Sapphire conference intros raise SAP integration questions

Unveiling of Salesforce challenger C/4HANA and lingering indirect licensing issue give mixed message about SAP's willingness to ...

• ### SAP quietly pulls the plug on SAP Anywhere

Users and analysts say technical limitations and a failure to adequately understand the SMB market contributed to the demise of ...

• ### New tools unveiled to monitor, manage and optimize SAP environments

Vendors announced software to help organizations move to SAP systems, including test automation, code profiling for HANA apps, ...

## SearchSQLServer

• ### Proposed Microsoft-GitHub buy confirms open source role in cloud

The looming Microsoft-GitHub pairing confirms the company's rebirth as an open source friend. Data tools on the Azure cloud are ...

• ### Common Data Service for Analytics eases Power BI integration

Integrating data into Power BI for analysis can be a challenge, but Microsoft's Common Data Service for Analytics technology is ...

• ### Power BI Report Server adds new Power BI reporting options

Updates to Power BI Report Server expand the on-premises platform's reporting functionality and increase the number of data ...

## TheServerSide.com

• ### How to git revert a commit: A simple undo changes example

The best way to undo previous changes to the source code repository is to learn how to git revert a commit.

• ### Jenkins vs. Maven: Compare these build and integration tools

DevOps advocates are often asked for a Jenkins vs. Maven comparison. But those asking often discover that Maven-Jenkins ...

• ### Jenkins environment variables list for shell script build jobs

The Jenkins environment variables list outlines the various properties that developers can inject into advanced Jenkins shell ...

## SearchDataCenter

• ### Why data centers need log management tools

Log files contain rich and useful management data. With the right software tools and a few navigation tips, you can maximize and ...

• ### HPE gives its memory-driven computing initiative another try

HPE has brought its memory-driven computing architecture back into the spotlight, this time with a little help from its friends ...

• ### HPE edge strategy reroutes data, apps around the cloud

HPE's upgraded converged infrastructure systems aim to help enterprises process and manage data outside their data centers and ...

## SearchContentManagement

• ### SharePoint hub sites raises migration questions among users

In the newest rev of SharePoint Online, what used to be sub-sites are now new freestanding sites. This change and others may ...

• ### Cloud DAM platforms vs. on premises for digital asset management

Learn about digital asset management and how cloud DAM democratizes media management and delivery across the enterprise while ...

• ### Box workflow gets upgrade with Progressly purchase

Box is hoping to upgrade its workflow capabilities by adding the startup Progressly to its team, while also still partnering with...

## SearchHRSoftware

• ### News roundup: TriNet software targets professional services

New specialized products include TriNet software for professional services, QuickBooks payroll for contractors and a ...

• ### AI can reduce workplace bias, says CEO of leading HR group

AI technology may help HR reduce workplace bias, according to Johnny Taylor, president and CEO of the Society for Human Resource ...

• ### How to create an effective employee retention plan

The unemployment rate is low, and your workers are likely being courted by other companies. Here's how to create retention ...

Close