Home » Developer & Programmer » Forms » show increasing digit 1 to 100 in a text field after pressing one by one
show increasing digit 1 to 100 in a text field after pressing one by one [message #594197] Mon, 26 August 2013 00:08 Go to next message
medisys
Messages: 18
Registered: March 2013
Location: Riyadh
Junior Member
hi
could any body give me the code for show increasing digit 1 to 100 in a text field after pressing a button 100 times?
thanks
Re: show increasing digit 1 to 100 in a text field after pressing one by one [message #594198 is a reply to message #594197] Mon, 26 August 2013 00:13 Go to previous messageGo to next message
BlackSwan
Messages: 23034
Registered: January 2009
Senior Member
medisys wrote on Sun, 25 August 2013 22:08
hi
could any body give me the code for show increasing digit 1 to 100 in a text field after pressing a button 100 times?
thanks


Does digit increase when you press your belly button even once?
Re: show increasing digit 1 to 100 in a text field after pressing one by one [message #594199 is a reply to message #594197] Mon, 26 August 2013 00:18 Go to previous messageGo to next message
Michel Cadot
Messages: 59751
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
How it this a SQL, or even Oracle, question?

Regards
Michel
Re: show increasing digit 1 to 100 in a text field after pressing one by one [message #594202 is a reply to message #594199] Mon, 26 August 2013 01:18 Go to previous messageGo to next message
Littlefoot
Messages: 19770
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Looks like a Forms question; if that's so, WHEN-BUTTON-PRESSED trigger would
:block.text_item := nvl(:block.text_item, 0) + 1;

Obviously, it won't stop on 100. Do you need it to stop? Or to start from 1 again? Or what?
Re: show increasing digit 1 to 100 in a text field after pressing one by one [message #595941 is a reply to message #594202] Mon, 16 September 2013 07:15 Go to previous messageGo to next message
medisys
Messages: 18
Registered: March 2013
Location: Riyadh
Junior Member
thanks littlefoot

its working but i like to add that when number is 100 then if press button then it will start from 1 again so can u please help me for that?
thanks
Re: show increasing digit 1 to 100 in a text field after pressing one by one [message #595943 is a reply to message #595941] Mon, 16 September 2013 07:23 Go to previous messageGo to next message
Michel Cadot
Messages: 59751
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Do NO report to get an answer.
Reporting a post is NOT for this purpose but to signal a post that violates the rules.
In addition, it is counter-productive as many will see this as an abuse (something that should be reported) and will not answer.

Regards
Michel
Re: show increasing digit 1 to 100 in a text field after pressing one by one [message #595944 is a reply to message #595941] Mon, 16 September 2013 07:43 Go to previous messageGo to next message
cookiemonster
Messages: 11177
Registered: September 2008
Location: Rainy Manchester
Senior Member
medisys wrote on Mon, 16 September 2013 13:15
thanks littlefoot

its working but i like to add that when number is 100 then if press button then it will start from 1 again so can u please help me for that?
thanks


So you need an if statement that checks the current value and if it's 100 sets it to 1 instead of incrementing it.
You really should be able to write that without any help.
Re: show increasing digit 1 to 100 in a text field after pressing one by one [message #595990 is a reply to message #595944] Tue, 17 September 2013 01:03 Go to previous messageGo to next message
Littlefoot
Messages: 19770
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Alternatively, DECODE (or CASE) could do the same job. Have a look at the following SQL*Plus example:
SQL> select nvl(decode(&text_item, 100, 0, &text_item), 0) + 1 from dual;
Enter value for text_item: 99
Enter value for text_item: 99

NVL(DECODE(99,100,0,99),0)+1
----------------------------
                         100

SQL> /
Enter value for text_item: 100
Enter value for text_item: 100

NVL(DECODE(100,100,0,100),0)+1
------------------------------
                             1

SQL> /
Enter value for text_item: null
Enter value for text_item: null

NVL(DECODE(NULL,100,0,NULL),0)+1
--------------------------------
                               1

SQL> /
Enter value for text_item: 25
Enter value for text_item: 25

NVL(DECODE(25,100,0,25),0)+1
----------------------------
                          26

SQL>
Re: show increasing digit 1 to 100 in a text field after pressing one by one [message #596000 is a reply to message #595990] Tue, 17 September 2013 03:57 Go to previous messageGo to next message
medisys
Messages: 18
Registered: March 2013
Location: Riyadh
Junior Member
thanks littlefoot. could you please help me for get any link for get idea about how to develop HOSPITAL INDICATOR application ?
Re: show increasing digit 1 to 100 in a text field after pressing one by one [message #596004 is a reply to message #596000] Tue, 17 September 2013 04:09 Go to previous messageGo to next message
Littlefoot
Messages: 19770
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
No idea, I've never even heard of anything like that. I should search for it (but you can use Google just as well as me).
Re: show increasing digit 1 to 100 in a text field after pressing one by one [message #596007 is a reply to message #596004] Tue, 17 September 2013 04:58 Go to previous messageGo to next message
medisys
Messages: 18
Registered: March 2013
Location: Riyadh
Junior Member
thanks littlefoot...

if i want to show the text of some numeric values like " $2549.50 = two thousand five hundred forty nine dollar fifty cent "" could you please give the code?
Re: show increasing digit 1 to 100 in a text field after pressing one by one [message #596008 is a reply to message #596007] Tue, 17 September 2013 05:16 Go to previous messageGo to next message
Lalit Kumar B
Messages: 2514
Registered: May 2013
Location: World Wide on the Web
Senior Member
Those are too many different questions in a single thread. Anyway, T.Kyte gave an answer slose to your requirement. You can tweak it a bit to decode the "$" sign and the cents after the decimal etc.

Have a look at Spell the numbers

Regards,
Lalit

[Updated on: Tue, 17 September 2013 05:17]

Report message to a moderator

Re: show increasing digit 1 to 100 in a text field after pressing one by one [message #596009 is a reply to message #596008] Tue, 17 September 2013 05:31 Go to previous messageGo to next message
medisys
Messages: 18
Registered: March 2013
Location: Riyadh
Junior Member
could you please give me a FMB what can read the amound?..............lalit kumar brother
Re: show increasing digit 1 to 100 in a text field after pressing one by one [message #596010 is a reply to message #596009] Tue, 17 September 2013 05:34 Go to previous messageGo to next message
Lalit Kumar B
Messages: 2514
Registered: May 2013
Location: World Wide on the Web
Senior Member
When I read that you need a code, I thought SQL or PL/SQL, however, it seems it has to do with forms. Someone goot at it might help with the FMB. Lets wait.
Re: show increasing digit 1 to 100 in a text field after pressing one by one [message #596011 is a reply to message #596009] Tue, 17 September 2013 06:18 Go to previous messageGo to next message
Littlefoot
Messages: 19770
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
medisys
give me a FMB what can read the amound?

What does that mean? What do you call "read"? If it is "how to spell a number", Lalit already pointed you to a working code Tom Kyte provided on his site. You'd have to create the same function (either in your schema or in a form) and call that function in WHEN-VALIDATE-ITEM trigger (for newly entered values) and/or POST-QUERY (for values fetched from the database).
Re: show increasing digit 1 to 100 in a text field after pressing one by one [message #596117 is a reply to message #596011] Wed, 18 September 2013 02:47 Go to previous messageGo to next message
medisys
Messages: 18
Registered: March 2013
Location: Riyadh
Junior Member
thanks a lot latin kumar & littlefoot brother but another problem is if i want to spell number like 150.20( should be like (one hundred fifty and twenty)) or if i want to spell 00.21 ( should be ( twenty one cent) its not working... please help
Re: show increasing digit 1 to 100 in a text field after pressing one by one [message #596123 is a reply to message #596117] Wed, 18 September 2013 03:16 Go to previous messageGo to next message
cookiemonster
Messages: 11177
Registered: September 2008
Location: Rainy Manchester
Senior Member
So post the code you are using, along with the results you are getting, and then we might be able to work out what the problem is.
Re: show increasing digit 1 to 100 in a text field after pressing one by one [message #596127 is a reply to message #596123] Wed, 18 September 2013 03:37 Go to previous messageGo to next message
medisys
Messages: 18
Registered: March 2013
Location: Riyadh
Junior Member
i created function spell_number........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;


and in when validate trigger i write the code ........ :spell:=spell_number(:nmbr);
Re: show increasing digit 1 to 100 in a text field after pressing one by one [message #596130 is a reply to message #596127] Wed, 18 September 2013 04:05 Go to previous messageGo to next message
cookiemonster
Messages: 11177
Registered: September 2008
Location: Rainy Manchester
Senior Member
1) Please read and follow How to use [code] tags and make your code easier to read?
2) I asked you show us the results you got as well.

I assume the problem is it doesn't handle decimals.

Add a new variable to the function to hold the decimal part, converted into a whole number so the conversion trick will work on it:
l_decimal varchar2(50) default MOD( round(p_number,2), 1)*100;


Then add a new bit of code at the end to convert that to words using to_char(to_Date()) and concatenate the result to the return variable.
Re: show increasing digit 1 to 100 in a text field after pressing one by one [message #596141 is a reply to message #596117] Wed, 18 September 2013 05:10 Go to previous messageGo to next message
Lalit Kumar B
Messages: 2514
Registered: May 2013
Location: World Wide on the Web
Senior Member
medisys wrote on Wed, 18 September 2013 13:17
thanks a lot latin kumar & littlefoot brother but another problem is if i want to spell number like 150.20( should be like (one hundred fifty and twenty)) or if i want to spell 00.21 ( should be ( twenty one cent) its not working... please help


latin? It's Lalit Smile

I have an example code, which you can tweak using the previous "spell the numbers" code to get your task done -

SQL> WITH DATA AS
  2   (SELECT '150.20' A FROM DUAL),
  3  T(A,
  4  B,
  5  C) AS
  6   (SELECT A, TO_CHAR(TO_DATE(SUBSTR(A, 1, 1), 'J'), 'JSP') B, 1 AS C
  7      FROM DATA
  8    UNION ALL
  9    SELECT A,
 10           CASE
 11              WHEN SUBSTR(A, C + 1, 1) = '.' THEN
 12               'DOLLARS AND'
 13              WHEN SUBSTR(A, C + 1, 1) = '0' THEN
 14               'ZERO'
 15              ELSE
 16               TO_CHAR(TO_DATE(SUBSTR(A, C + 1, 1), 'J'), 'JSP')
 17           END B,
 18           C + 1 AS C
 19      FROM T
 20     WHERE C < LENGTH(A))
 21  SELECT LISTAGG (B, ' ') WITHIN GROUP (ORDER BY C) ||' '|| 'CENTS' AS "SPELLED" FROM T
 22  /
 
SPELLED
--------------------------------------------------------------------------------
ONE FIVE ZERO DOLLARS AND TWO ZERO CENTS


Regards,
Lalit
Re: show increasing digit 1 to 100 in a text field after pressing one by one [message #596214 is a reply to message #596141] Thu, 19 September 2013 01:02 Go to previous messageGo to next message
medisys
Messages: 18
Registered: March 2013
Location: Riyadh
Junior Member
cookiemonster brother could you please add necessary code for spell the number after decimal in my function

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;
Re: show increasing digit 1 to 100 in a text field after pressing one by one [message #596215 is a reply to message #596214] Thu, 19 September 2013 01:14 Go to previous messageGo to next message
Littlefoot
Messages: 19770
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Split a number into two parts: before and after a decimal character. You'd do that by converting a number to a string (TO_CHAR) and apply SUBSTR and INSTR functions. Then spell each of these parts separately and, finally, display a concatenated result.
icon6.gif  Re: show increasing digit 1 to 100 in a text field after pressing one by one [message #596216 is a reply to message #596214] Thu, 19 September 2013 01:16 Go to previous messageGo to next message
Michel Cadot
Messages: 59751
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

AskTom's Spell the number.

Re: show increasing digit 1 to 100 in a text field after pressing one by one [message #596217 is a reply to message #596216] Thu, 19 September 2013 01:20 Go to previous messageGo to next message
Littlefoot
Messages: 19770
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Lalit already pointed the OP to that link two days ago (but I suppose it won't do any harm to re-read it, eh?).
Re: show increasing digit 1 to 100 in a text field after pressing one by one [message #596222 is a reply to message #596217] Thu, 19 September 2013 02:37 Go to previous messageGo to next message
cookiemonster
Messages: 11177
Registered: September 2008
Location: Rainy Manchester
Senior Member
I've already supplied the code to get the decimal bit.
Myself and Littlefoot and have described what you need to do with it.
You really need to try it yourself, it's not difficult since you already have example code to base it on.
If we supply all the code you'll never learn how it works and you really need to.
If you get stuck post what you tried and we will help, but we're not doing it all for you.
Re: show increasing digit 1 to 100 in a text field after pressing one by one [message #597104 is a reply to message #596222] Tue, 01 October 2013 01:10 Go to previous messageGo to next message
medisys
Messages: 18
Registered: March 2013
Location: Riyadh
Junior Member
thanks cookiemonster brother..i got u...
another problem is i have created a report at oracle reports 6i what showing the values total number of discharge patients during a period in a hospital and now i like to show those values through a chart is it possible?
Re: show increasing digit 1 to 100 in a text field after pressing one by one [message #597112 is a reply to message #597104] Tue, 01 October 2013 03:29 Go to previous message
cookiemonster
Messages: 11177
Registered: September 2008
Location: Rainy Manchester
Senior Member
Maybe, but you should create a new topic for this in the reports forum and supply more details of what you want the output to look like.
Previous Topic: How to Run Oracle Form Server 10g From IPhone
Next Topic: How to get rid of FRM-41051 error?
Goto Forum:
  


Current Time: Sun Nov 23 22:16:01 CST 2014

Total time taken to generate the page: 0.11985 seconds