Wht is the logic to find whether the entered input is a number or the character. How can we design this program using a procedure or the function

Questions by srinivas22338   answers by srinivas22338

Showing Answers 1 - 9 of 9 Answers

Pulakesh Dey

  • Apr 24th, 2007
 

The value will be given as parameter inside ascii() function
------------------------------------------------------------------------------
SELECT DECODE(COUNT(N),0,'CHARACTOR','NUMBER') FROM
(
SELECT 1 N FROM DUAL
WHERE ASCII('A') BETWEEN 48 AND 57
)
WHERE N(+)=1

  Was this answer useful?  Yes

PratikshaD

  • Jun 12th, 2009
 

You can use translate function.translate(,'~0123456789','~') will return null if the input is numeric. Not null if the input is alphanumeric.

  Was this answer useful?  Yes

sriatit

  • Oct 12th, 2009
 

You can check this by using translate function. If the return value is NULL then the input is a number else it  is character or alpha numeric.
Ex:
select ('abcd', '~0123456789', '~') from dual; -- Will return a non null value
select (123, '~0123456789', '~') from dual; -- Will return a null value
select ('123', '~0123456789', '~') from dual; -- Will return a null value
select ('123a', '~0123456789', '~') from dual; -- Will return a non null value
select ('', '~0123456789', '~') from dual; -- Will return a null value. Ensure you dont pass null values.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions