| Author | 
		  Message
		 | 
		
		  | prasannanb | 
		  
		    
			  
				 Posted: Thu Jul 19, 2012 4:02 am    Post subject: Hex conversion | 
				     | 
			   
			 
		   | 
		
		
		   Apprentice
 
 Joined: 17 Apr 2009 Posts: 35
  
  | 
		  
		    
			  
				How can I convert hex value to decimal in esql.
 
Ex: input: A (as characters)
 
     output: 10 (as integer)
 
 
Please help     | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | kimbert | 
		  
		    
			  
				 Posted: Thu Jul 19, 2012 4:45 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		    Jedi Council
 
 Joined: 29 Jul 2003 Posts: 5543 Location: Southampton 
  | 
		  
		    
			  
				That's a very basic question. I know the answer, but I refuse to give you the answer until you answer the following questions:
 
- what is your message flow trying to do ( why do you need to do this) ?
 
- have you considered using the MRM or DFDL parser to do this conversion?
 
- Did you look for the answer in the WMB info center before posting? | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | prasannanb | 
		  
		    
			  
				 Posted: Thu Jul 19, 2012 11:16 pm    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		   Apprentice
 
 Joined: 17 Apr 2009 Posts: 35
  
  | 
		  
		    
			  
				The answer is:
 
1) prefix the incoming hex chars with 0x
 
ex: DECLARE cC CHARACTER '0x' || FIELDVALUE(InputRoot.MRM.hexval)
 
2) Cast char to int
 
DECLARE nN INTEGER CAST(cC AS INTEGER CCSID 1208);
 
 
Thanks for the help    | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | mqjeff | 
		  
		    
			  
				 Posted: Fri Jul 20, 2012 6:25 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		   Grand Master
 
 Joined: 25 Jun 2008 Posts: 17447
  
  | 
		  
		    
			  
				
   
	| prasannanb wrote: | 
   
  
	The answer is:
 
1) prefix the incoming hex chars with 0x
 
ex: DECLARE cC CHARACTER '0x' || FIELDVALUE(InputRoot.MRM.hexval)
 
2) Cast char to int
 
DECLARE nN INTEGER CAST(cC AS INTEGER CCSID 1208);
 
 
Thanks for the help    | 
   
 
 
 
No, that's a solution, not *the* answer. | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | fjb_saper | 
		  
		    
			  
				 Posted: Sat Jul 21, 2012 7:34 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		    Grand High Poobah
 
 Joined: 18 Nov 2003 Posts: 20768 Location: LI,NY 
  | 
		  
		    
			  
				
   
	| mqjeff wrote: | 
   
  
	
   
	| prasannanb wrote: | 
   
  
	The answer is:
 
1) prefix the incoming hex chars with 0x
 
ex: DECLARE cC CHARACTER '0x' || FIELDVALUE(InputRoot.MRM.hexval)
 
2) Cast char to int
 
DECLARE nN INTEGER CAST(cC AS INTEGER CCSID 1208);
 
 
Thanks for the help    | 
   
 
 
 
No, that's a solution, not *the* answer. | 
   
 
 
Especially as the question is still quite unclear. We have no idea why he wants/needs to do this...   _________________ MQ & Broker admin | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | 
		    
		   |