Home » Developer & Programmer » Forms » To spell a number in SQL (forms 10g)
To spell a number in SQL [message #507803] Wed, 18 May 2011 01:29 Go to next message
poojamunj
Messages: 64
Registered: May 2011
Location: MUMBAI
Member
hi all1
I have two fields in my form
In one field I am entering cetain amount
I want the conversion of that amount to char in next field
for e.g 1000 one thousand
how can i achieve this.
please help.
thnks.
Re: conversion of number to char [message #507804 is a reply to message #507803] Wed, 18 May 2011 01:38 Go to previous messageGo to next message
Littlefoot
Messages: 21818
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Is AskTom's "Spell the number" what you are looking for?
Re: conversion of number to char [message #507807 is a reply to message #507804] Wed, 18 May 2011 01:47 Go to previous messageGo to next message
poojamunj
Messages: 64
Registered: May 2011
Location: MUMBAI
Member
since i am having two fields
I am entering few digits say an amount in that field for e.g 2500
I want to display two thousand five hundred in next field
in short i want to spell that number.
How can i do this at form level or is there any other way.
Re: conversion of number to char [message #507812 is a reply to message #507807] Wed, 18 May 2011 02:11 Go to previous messageGo to next message
Littlefoot
Messages: 21818
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
I have a feeling that you didn't read what Tom said, did you?

As you use Forms, you'll have to copy his suggestion into your trigger (or a procedure, whatever). Your "input" is first item's value, your "output" is what Tom's query returns.
to spell a number in sql [message #508084 is a reply to message #507803] Thu, 19 May 2011 06:36 Go to previous messageGo to next message
poojamunj
Messages: 64
Registered: May 2011
Location: MUMBAI
Member
Hi!
i tried a simple query through which i was able to spell a number
The query is:

SELECT initcap(TO_CHAR(TO_DATE(6482, 'J'), 'JSP') )FROM DUAL;

by running this query on sql prompt I ma able to get result till 99999 ie ninty nine thousand nine hundred and ninty nine.

But i created a trigger on key-next-item stating:

I_AMT VARCHAR2(100);
I_NO NUMBER (30);

begin

I_NO := :TIT_AMT;


SELECT INITCAP(TO_CHAR(TO_DATE(I_NO, 'J'), 'JSP'))
INTO I_AMT
FROM DUAL;


:RUPEES := I_AMT;

end;

there were no compilation errors, but the problem is the amount is not exceeding more than 9910 at form level. Its giving an error called key-next-item trigger raised unhandled exception.
How can i make it dynamic so that it can accept lager digits.
please help.
thanks.
Re: to spell a number in sql [message #508086 is a reply to message #508084] Thu, 19 May 2011 06:42 Go to previous messageGo to next message
ramoradba
Messages: 2456
Registered: January 2009
Location: AndhraPradesh,Hyderabad,I...
Senior Member
http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:1407603857650
Quote:
by running this query on sql prompt I ma able to get result till 99999 ie ninty nine thousand nine hundred and ninty nine.


I am sorry I did n`t read it before.

Sriram

[Updated on: Thu, 19 May 2011 06:51]

Report message to a moderator

Re: to spell a number in sql [message #508088 is a reply to message #508086] Thu, 19 May 2011 06:43 Go to previous messageGo to next message
Littlefoot
Messages: 21818
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Quote:
key-next-item trigger raised unhandled exception.

Which "unhandled" exception is it? FRM-xxxxx, ORA-xxxxx?
Re: to spell a number in sql [message #508202 is a reply to message #508088] Thu, 19 May 2011 23:23 Go to previous messageGo to next message
poojamunj
Messages: 64
Registered: May 2011
Location: MUMBAI
Member
FRM-40735:KEY-NEXT-ITEM trigger raised unhandled exception ORA-06502
this was the error which i faced.
Re: to spell a number in sql [message #508209 is a reply to message #508202] Fri, 20 May 2011 00:11 Go to previous messageGo to next message
Littlefoot
Messages: 21818
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
That should be easy to fix.
Oracle

ORA-06502: PL/SQL: numeric or value errorstring

Cause: An arithmetic, numeric, string, conversion, or constraint error occurred. For example, this error occurs if an attempt is made to assign the value NULL to a variable declared NOT NULL, or if an attempt is made to assign an integer larger than 99 to a variable declared NUMBER(2).

Action: Change the data, how it is manipulated, or how it is declared so that values do not violate constraints.
Re: To spell a number in SQL [message #508717 is a reply to message #507803] Tue, 24 May 2011 03:27 Go to previous messageGo to next message
oralover2006
Messages: 144
Registered: January 2010
Location: India
Senior Member
first create this function in your Forms program unit then after entry in :TIT_AMT call this function as:

:RUPEES := GET_IN_WORDS (:TIT_AMT);


CREATE OR REPLACE FUNCTION GET_IN_WORDS (MNUM NUMBER) return varchar2 is
  mil        varchar2(50)  := '       TRILLIONBILLION MILLION THOUSAND   ';
  mWords     varchar2(180) := '';
  mAmount    number        := 0;
  ctr        number(3)     := 0;		
  num3       number(3)     := 0;
  num4       number(3)     := instr(to_char(mNum),'.');
  numDecimal varchar2(5)   := 0;
begin
  if num4 = 0 then
     numDecimal := '0.00';
     mAmount    := mNum;
  else
     numDecimal := '0'||ltrim(substr(to_char(mNum),num4,4));
     mAmount    := to_number(substr(to_char(mNum),1,num4-1));
  end if;
LOOP
  ctr := nvl(ctr,0) + 1;
  if ctr > 5 then
     exit ;
   end if;
   Num3   := to_number(nvl(substr(lpad(to_char(mAmount),15,'0'),ctr*3-2,3),'0'));
   if Num3 > 0 then
      mWords := mWords || ' ' || to_char(to_date(Num3,'J'),'JSP');
      mWords := mWords ||' '|| rtrim(substr(Mil,ctr*8,8));
   end if;
END LOOP;
 mWords := mWords || ' And '||numDecimal;
 return (mwords);
end;
/


you have to play with this function to trap/catch errors, if any.
don't forget to give your feedback.
regards.
Re: To spell a number in SQL [message #508720 is a reply to message #508717] Tue, 24 May 2011 03:41 Go to previous messageGo to next message
Michel Cadot
Messages: 68675
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
The function is AskTom site given above contains far better functions than yours.
You should read it.

Don't forget to give your feedback.

Regards
Michel
Re: To spell a number in SQL [message #508722 is a reply to message #508720] Tue, 24 May 2011 04:09 Go to previous message
ramoradba
Messages: 2456
Registered: January 2009
Location: AndhraPradesh,Hyderabad,I...
Senior Member
For Indian Currency System

Sriram
Previous Topic: Button
Next Topic: oracle.forms.webutil.file.filefunctions bean not found webutil_file.file_selection_dialog_int will
Goto Forum:
  


Current Time: Sat Sep 07 15:37:03 CDT 2024