| Author | 
		  Message
		 | 
		
		  | CAONIMA | 
		  
		    
			  
				 Posted: Wed Mar 11, 2015 12:45 pm    Post subject: Add zero before BLOB message | 
				     | 
			   
			 
		   | 
		
		
		   Acolyte
 
 Joined: 03 Dec 2014 Posts: 65
  
  | 
		  
		    
			  
				Hi All,
 
 
I will change the CorrelId  and the value needs to be the value of RootElement of the XML document (input message).
 
 
The data type of RootElement is CHAR.
 
 
So I need to  CAST the RootElement to BLOB.
 
 
If it less than 24 bytes, I will add zeros before it.
 
 
The CorrelId is BLOB, so I CAST the RootElement as BLOB fist.
 
 
But I don't know how to add zero before it.
 
 
It said: Invalid or incompatible data types for '||' operator.
 
 
Here is my code:
 
 
 
   
	| Code: | 
   
  
	DECLARE RootValueBlob BLOB CAST(Root_Element AS BLOB CCSID InputRoot.Properties.CodedCharSetId);
 
   
 
       
 
       DECLARE LEN INT;
 
   
 
      SET LEN = LENGTH(RootValueBlob);
 
      
 
      WHILE (LEN < 24)
 
         DO
 
         SET RootValueBlob=RIGHT('0'||RootValueBlob,24);
 
         SET LEN = LEN +1;
 
      END WHILE; | 
   
 
 
 
After '||', it cannot connect the BLOB data type.
 
 
So how should I do?
 
 
Thank you very much. | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | fjb_saper | 
		  
		    
			  
				 Posted: Wed Mar 11, 2015 12:55 pm    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		    Grand High Poobah
 
 Joined: 18 Nov 2003 Posts: 20768 Location: LI,NY 
  | 
		  
		    
			  
				Well your char is a hex representation of 24 bytes and needs 48 chars.
 
So why don't you use the char to append / prepend char '0' until the total is 48 chars and only then cast it to BLOB?
 
 
Your problem is because your are trying to concatenage a char with a blob.
 
You should be trying to concatenate a hex 00 with the blob or a char with the char.    _________________ MQ & Broker admin | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | kimbert | 
		  
		    
			  
				 Posted: Thu Mar 12, 2015 4:41 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		    Jedi Council
 
 Joined: 29 Jul 2003 Posts: 5543 Location: Southampton 
  | 
		  
		    
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | CAONIMA | 
		  
		    
			  
				 Posted: Thu Mar 12, 2015 4:58 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		   Acolyte
 
 Joined: 03 Dec 2014 Posts: 65
  
  | 
		  
		    
			  
				
   
	| fjb_saper wrote: | 
   
  
	Well your char is a hex representation of 24 bytes and needs 48 chars.
 
So why don't you use the char to append / prepend char '0' until the total is 48 chars and only then cast it to BLOB?
 
 
Your problem is because your are trying to concatenage a char with a blob.
 
You should be trying to concatenate a hex 00 with the blob or a char with the char.    | 
   
 
 
 
Thank you for you reply,
 
 
When I add char'0' until the total is 48 chars, and CAST it to BLOB.
 
 
The BLOB return the '0000' are '3030'
 
 
What is the problem? | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | fjb_saper | 
		  
		    
			  
				 Posted: Thu Mar 12, 2015 5:00 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		    Grand High Poobah
 
 Joined: 18 Nov 2003 Posts: 20768 Location: LI,NY 
  | 
		  
		    
			  
				You mean something like
 
 
   
	| Code: | 
   
  
	SET insertstr = replicate('0', 48 -length(id));
 
result = overlay(id placing  insertstr from 0 for 0); | 
   
 
 _________________ MQ & Broker admin | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | CAONIMA | 
		  
		    
			  
				 Posted: Thu Mar 12, 2015 5:28 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		   Acolyte
 
 Joined: 03 Dec 2014 Posts: 65
  
  | 
		  
		    
			  
				
   
	| fjb_saper wrote: | 
   
  
	You mean something like
 
 
   
	| Code: | 
   
  
	SET insertstr = replicate('0', 48 -length(id));
 
result = overlay(id placing  insertstr from 0 for 0); | 
   
 
 | 
   
 
 
 
Thank you for your reply, I think the problem solved | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | 
		    
		   |