| Author | 
		  Message
		 | 
		
		  | DELLIPIZ | 
		  
		    
			  
				 Posted: Fri Nov 19, 2004 8:21 am    Post subject: Extracting data from a BLOB | 
				     | 
			   
			 
		   | 
		
		
		   Acolyte
 
 Joined: 08 Oct 2003 Posts: 70
  
  | 
		  
		    
			  
				Hi, 
 
 
My input is in BLOB.  (Message Domain = BLOB).  It is really legacy data, but since I won't know what the structure is, I am treating it as a BLOB, instead of an MRM.
 
 
I need to capture certain positions of that data.
 
 
For example, I need to extract data in position 5.  So I tried putting
 
SET OutputRoot = SUBSTRING(InputRoot FROM 5 FOR 1);
 
 
But it's failing when I run it.   Any idea how I could extract data from a BLOB?
 
 
Thanks!
 
 
-Lori | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | jefflowrey | 
		  
		    
			  
				 Posted: Fri Nov 19, 2004 8:31 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		   Grand Poobah
 
 Joined: 16 Oct 2002 Posts: 19981
  
  | 
		  
		    
			  
				You can access the BLOB field you are interested in at InputRoot.BLOB.BLOB, not at InputRoot.
 
 
Or at InputBody.BLOB. _________________ I am *not* the model of the modern major general. | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | DELLIPIZ | 
		  
		    
			  
				 Posted: Fri Nov 19, 2004 8:54 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		   Acolyte
 
 Joined: 08 Oct 2003 Posts: 70
  
  | 
		  
		    
			  
				I tried this and it didn't work:
 
 
SET OutputRoot = SUBSTRING(InputBody.BLOB FROM 1 FOR 4);
 
 
to try to get the first four positions.  
 
 
What did I do wrong?
 
 
Thanks! | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | jefflowrey | 
		  
		    
			  
				 Posted: Fri Nov 19, 2004 9:02 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		   Grand Poobah
 
 Joined: 16 Oct 2002 Posts: 19981
  
  | 
		  
		    
			  
				You can't assign directly to OutputRoot either. _________________ I am *not* the model of the modern major general. | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | kirani | 
		  
		    
			  
				 Posted: Fri Nov 19, 2004 10:03 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		   Jedi Knight
 
 Joined: 05 Sep 2001 Posts: 3779 Location: Torrance, CA, USA 
  | 
		  
		    
			  
				Depending on your output message format you need to code your ESQL. For example, if the output message format is XML then the ESQL code would be,
 
   
	| Code: | 
   
  
	
 
SET OutputRoot.XML.MyData = SUBSTRING(CAST(InputRoot."BLOB"."BLOB" AS CHAR CCSID InputRoot.Properties.CodedCharSetId) FROM 5 FOR 1);
 
 | 
   
 
 _________________ Kiran
 
 
 
IBM Cert. Solution Designer & System Administrator - WBIMB V5
 
IBM Cert. Solutions Expert - WMQI
 
IBM Cert. Specialist - WMQI, MQSeries
 
IBM Cert. Developer - MQSeries
 
 
 | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | jefflowrey | 
		  
		    
			  
				 Posted: Fri Nov 19, 2004 10:24 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		   Grand Poobah
 
 Joined: 16 Oct 2002 Posts: 19981
  
  | 
		  
		    
			  
				I think SUBSTRING is supposed to work on all of the "character" types, including BLOB. _________________ I am *not* the model of the modern major general. | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | kirani | 
		  
		    
			  
				 Posted: Fri Nov 19, 2004 11:02 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		   Jedi Knight
 
 Joined: 05 Sep 2001 Posts: 3779 Location: Torrance, CA, USA 
  | 
		  
		    
			  
				Yes, but he will HEX character if he uses SUBSTRING on BLOB. I think he wants the actual CHARACTER/data from the message. _________________ Kiran
 
 
 
IBM Cert. Solution Designer & System Administrator - WBIMB V5
 
IBM Cert. Solutions Expert - WMQI
 
IBM Cert. Specialist - WMQI, MQSeries
 
IBM Cert. Developer - MQSeries
 
 
 | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | Tibor | 
		  
		    
			  
				 Posted: Tue Nov 23, 2004 3:13 pm    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		    Grand Master
 
 Joined: 20 May 2001 Posts: 1033 Location: Hungary 
  | 
		  
		    
			  
				
   
	| kirani wrote: | 
   
  
	Depending on your output message format you need to code your ESQL. For example, if the output message format is XML then the ESQL code would be,
 
   
	| Code: | 
   
  
	SET OutputRoot.XML.MyData = SUBSTRING(CAST(InputRoot."BLOB"."BLOB" AS CHAR CCSID InputRoot.Properties.CodedCharSetId) FROM 5 FOR 1);
 
 | 
   
 
 | 
   
 
 
 
I would recommend to change the order of CAST and SUBSTRING depending on the length of input.
 
 
   
	| Code: | 
   
  
	SET OutputRoot.XML.MyData = CAST(SUBSTRING(InputRoot."BLOB"."BLOB" FROM 5 FOR 1) AS CHAR CCSID InputRoot.Properties.CodedCharSetId) ;
 
 | 
   
 
 
 
Tibor | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | kirani | 
		  
		    
			  
				 Posted: Tue Nov 23, 2004 11:23 pm    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		   Jedi Knight
 
 Joined: 05 Sep 2001 Posts: 3779 Location: Torrance, CA, USA 
  | 
		  
		    
			  
				I think it will throw exception if the order is changed with current code. 
 
It will work only if you put FROM 5 FOR 2 instead of FROM 5 FOR 1. _________________ Kiran
 
 
 
IBM Cert. Solution Designer & System Administrator - WBIMB V5
 
IBM Cert. Solutions Expert - WMQI
 
IBM Cert. Specialist - WMQI, MQSeries
 
IBM Cert. Developer - MQSeries
 
 
 | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | Tibor | 
		  
		    
			  
				 Posted: Wed Nov 24, 2004 12:52 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		    Grand Master
 
 Joined: 20 May 2001 Posts: 1033 Location: Hungary 
  | 
		  
		    
			  
				
   
	| kirani wrote: | 
   
  
	I think it will throw exception if the order is changed with current code. 
 
It will work only if you put FROM 5 FOR 2 instead of FROM 5 FOR 1. | 
   
 
 
Kiran,
 
 
The function SUBSTRING works correctly on BLOB and results BLOB, that's why I recommend it for first step. The atomic element is the byte inside a BLOB, so odd positioning is allowed. 
 
 
Another reason is the speed: any operation on a BLOB value is far faster than othen types.  Our brokers have to work with very big messages and I prefer BLOB type based processing in this case as far as possible.
 
 
Tibor | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | 
		    
		   |