| Author | 
		  Message
		 | 
		
		  | saulgoodman | 
		  
		    
			  
				 Posted: Mon May 15, 2017 5:10 am    Post subject: CAST Function | 
				     | 
			   
			 
		   | 
		
		
		    Newbie
 
 Joined: 15 May 2017 Posts: 3
  
  | 
		  
		    
			  
				Hello Folks,
 
 
I want to check in a string whether it contains all numbers or some characters.
 
I was thinking of using CAST function. By this, I wanted to cast the string to integer and see if we get success.
 
But I am stuck at handling the condition!
 
What can I do to check if the string is successfully cast?
 
Can flagging help here? What is the default return of CAST function?
 
 
Thanks in advance. | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | Vitor | 
		  
		    
			  
				 Posted: Mon May 15, 2017 5:17 am    Post subject: Re: CAST Function | 
				     | 
			   
			 
		   | 
		
		
		    Grand High Poobah
 
 Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA 
  | 
		  
		    
			  
				
   
	| saulgoodman wrote: | 
   
  
	| What is the default return of CAST function? | 
   
 
 
 
Erm....whatever you set it to be in the DEFAULT option?       _________________ Honesty is the best policy.
 
Insanity is the best defence. | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | Vitor | 
		  
		    
			  
				 Posted: Mon May 15, 2017 5:23 am    Post subject: Re: CAST Function | 
				     | 
			   
			 
		   | 
		
		
		    Grand High Poobah
 
 Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA 
  | 
		  
		    
			  
				
   
	| saulgoodman wrote: | 
   
  
	| I was thinking of using CAST function. | 
   
 
 
 
I'd be more inclined to use TRANSLATE. _________________ Honesty is the best policy.
 
Insanity is the best defence. | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | saulgoodman | 
		  
		    
			  
				 Posted: Mon May 15, 2017 5:46 am    Post subject: Re: CAST Function | 
				     | 
			   
			 
		   | 
		
		
		    Newbie
 
 Joined: 15 May 2017 Posts: 3
  
  | 
		  
		    
			  
				
   
	| Vitor wrote: | 
   
  
	
   
	| saulgoodman wrote: | 
   
  
	| I was thinking of using CAST function. | 
   
 
 
 
I'd be more inclined to use TRANSLATE. | 
   
 
 
 
Ok, can you please give example, how TRANSLATE can be used in my case?
 
Your help is appreciated.   | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | Vitor | 
		  
		    
			  
				 Posted: Mon May 15, 2017 5:55 am    Post subject: Re: CAST Function | 
				     | 
			   
			 
		   | 
		
		
		    Grand High Poobah
 
 Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA 
  | 
		  
		    
			  
				
   
	| saulgoodman wrote: | 
   
  
	| Ok, can you please give example, how TRANSLATE can be used in my case? | 
   
 
 
 
Check of the LENGTH of the string once you've removed all the numeric characters from the string with TRANSLATE. If the length is 0, it was fully numeric. _________________ Honesty is the best policy.
 
Insanity is the best defence. | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | saulgoodman | 
		  
		    
			  
				 Posted: Mon May 15, 2017 6:31 am    Post subject: Re: CAST Function | 
				     | 
			   
			 
		   | 
		
		
		    Newbie
 
 Joined: 15 May 2017 Posts: 3
  
  | 
		  
		    
			  
				
   
	| Vitor wrote: | 
   
  
	
 
 
Check of the LENGTH of the string once you've removed all the numeric characters from the string with TRANSLATE. If the length is 0, it was fully numeric. | 
   
 
 
 
Thanks a lot mate!! 
 
IT WORKED!       | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | Vitor | 
		  
		    
			  
				 Posted: Mon May 15, 2017 6:33 am    Post subject: Re: CAST Function | 
				     | 
			   
			 
		   | 
		
		
		    Grand High Poobah
 
 Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA 
  | 
		  
		    
			  
				
   
	| saulgoodman wrote: | 
   
  
	
 
Thanks a lot mate!! 
 
IT WORKED!       | 
   
 
 
 
Despite appearances to the contrary, I do (sometimes) know what I'm talking about.
 
 
Glad you have an acceptable solution. _________________ Honesty is the best policy.
 
Insanity is the best defence. | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | 
		    
		   |