GeekInterview.com
   Home |  Tech FAQ  |   Interview Questions |  Placement Papers |  Tech Articles |  Learn |  Freelance Projects |  Online Testing |  Geeks Talk |  Job Postings |  Knowledge Base | Site Search |  Add/Ask Question

  GeekInterview.com  >  Interview Questions  >  Oracle  >  Programmatic Constructs

 Print  |  
Question:  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



October 10, 2009 14:32:12 #3
 sriatit   Member Since: December 2008    Total Comments: 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.
     

 

Back To Question