Convert numbers to Indian Rupees format in Oracle Forms / Reports.
Create the below mention function in Oracle Forms / Reports and call it with passing a number parameter.
FUNCTION INR_words( p_number In number, vFrDec varchar2 Default 'Paisa Only')
RETURN varchar2 As
TYPE myArray Is Table Of varchar2(255);
TYPE myArray2 Is Table Of varchar2(255);
l_str myArray := myArray( '',
' Thousand ', ' Lac ',
' Crore ', ' Arab ',
' Kharab ', ' quintillion ',
' Sextillion ', ' Septillion ',
' Octillion ', ' Nonillion ',
' Decillion ', ' Undecillion ',
' Duodecillion ' );
l_str2 myArray2 := myArray2('Rs Paisa', '$ Pany');
l_num varchar2(50) Default Trunc( p_number );
l_dec varchar2(50) Default Substr(To_Char(p_number - Trunc(p_number), '.99'),2);
l_return varchar2(4000);
j number := 3;
BEGIN
For i In 1 .. l_str.Count
LOOP
EXIT When l_num Is Null;
IF ( Substr(l_num, Length(l_num)-(j-1), j) <> 0 ) Then
l_return := To_Char(To_Date(
Substr(l_num, Length(l_num)-(j-1), j),'J' ), 'Jsp' ) || l_str(i) || l_return;
END IF;
l_num := Substr( l_num, 1, Length(l_num)-j );
j:=2;
END LOOP;
IF l_dec > 0 Then
l_return := rtrim(l_return) || ' and ' || rtrim(inr_words(Substr(l_dec,2), Null)) || ' ' || rtrim(Initcap(vFrdec));
END IF;
RETURN Replace(l_return, '-', ' ');
END;
Create the below mention function in Oracle Forms / Reports and call it with passing a number parameter.
FUNCTION INR_words( p_number In number, vFrDec varchar2 Default 'Paisa Only')
RETURN varchar2 As
TYPE myArray Is Table Of varchar2(255);
TYPE myArray2 Is Table Of varchar2(255);
l_str myArray := myArray( '',
' Thousand ', ' Lac ',
' Crore ', ' Arab ',
' Kharab ', ' quintillion ',
' Sextillion ', ' Septillion ',
' Octillion ', ' Nonillion ',
' Decillion ', ' Undecillion ',
' Duodecillion ' );
l_str2 myArray2 := myArray2('Rs Paisa', '$ Pany');
l_num varchar2(50) Default Trunc( p_number );
l_dec varchar2(50) Default Substr(To_Char(p_number - Trunc(p_number), '.99'),2);
l_return varchar2(4000);
j number := 3;
BEGIN
For i In 1 .. l_str.Count
LOOP
EXIT When l_num Is Null;
IF ( Substr(l_num, Length(l_num)-(j-1), j) <> 0 ) Then
l_return := To_Char(To_Date(
Substr(l_num, Length(l_num)-(j-1), j),'J' ), 'Jsp' ) || l_str(i) || l_return;
END IF;
l_num := Substr( l_num, 1, Length(l_num)-j );
j:=2;
END LOOP;
IF l_dec > 0 Then
l_return := rtrim(l_return) || ' and ' || rtrim(inr_words(Substr(l_dec,2), Null)) || ' ' || rtrim(Initcap(vFrdec));
END IF;
RETURN Replace(l_return, '-', ' ');
END;