GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Interview Questions  >  Oracle  >  Programmatic Constructs
Go To First  |  Previous Question  |  Next Question 
 Programmatic Constructs  |  Question 9 of 13    Print  
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

  
Total Answers and Comments: 3 Last Update: October 13, 2009     Asked by: srinivas22338 
  
 Sponsored Links

 
 Best Rated Answer

No best answer available. Please pick the good answer available or submit your answer.
April 24, 2007 04:26:07   #1  
Pulakesh Dey        

RE: wht is the logic to find whether the entered inpu...
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

 
Is this answer useful? Yes | No
June 12, 2009 06:01:53   #2  
PratikshaD Member Since: January 2009   Contribution: 2    

RE: 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
You can use translate function.translate( '~0123456789' '~') will return null if the input is numeric. Not null if the input is alphanumeric.
 
Is this answer useful? Yes | No
October 12, 2009 14:32:12   #3  
sriatit Member Since: December 2008   Contribution: 2    

RE: 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
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.

 
Is this answer useful? Yes | No


 
Go To Top


 Sponsored Links

 
About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape