| Author | 
		  Message
		 | 
		
		  | chaitu | 
		  
		    
			  
				 Posted: Mon May 16, 2016 1:12 am    Post subject: How to support empty value in xml field using esql | 
				     | 
			   
			 
		   | 
		
		
		   Voyager
 
 Joined: 15 Apr 2014 Posts: 89
  
  | 
		  
		    
			  
				Hi All,
 
 
I am trying to build a xml tree using esql like
 
 
   
	| Code: | 
   
  
	
 
 SET ADR1 = '0';
 
 SET ADR2 = '0';
 
 SET ADR3 = '"P"';
 
 SET ADR4 = CAST(InputRoot.DFDL.ECI_DEMO_ADR_LINE_1 AS
 
CHARACTER);
 
 CREATE LASTCHILD OF OutputRoot DOMAIN('XMLNSC');
 
 SET OutputRoot.XMLNSC.Data =(ADR1 || ',' || ADR2 || ',' ||ADR3 ||','||ADR4);
 
 | 
   
 
 
 
If I get a value on ADR4 I am able to create the outputroot 
 
but if ADR4 is empty then iam not able to create the output tree.
 
 
can anyone give any suggestions on this.
 
Thanks in Advance. | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | maurito | 
		  
		    
			  
				 Posted: Mon May 16, 2016 1:22 am    Post subject: Re: How to support empty value in xml field using esql | 
				     | 
			   
			 
		   | 
		
		
		   Partisan
 
 Joined: 17 Apr 2014 Posts: 358
  
  | 
		  
		    
			  
				
   
	| chaitu wrote: | 
   
  
	Hi All,
 
 
I am trying to build a xml tree using esql like
 
 
   
	| Code: | 
   
  
	
 
 SET ADR1 = '0';
 
 SET ADR2 = '0';
 
 SET ADR3 = '"P"';
 
 SET ADR4 = CAST(InputRoot.DFDL.ECI_DEMO_ADR_LINE_1 AS
 
CHARACTER);
 
 CREATE LASTCHILD OF OutputRoot DOMAIN('XMLNSC');
 
 SET OutputRoot.XMLNSC.Data =(ADR1 || ',' || ADR2 || ',' ||ADR3 ||','||ADR4);
 
 | 
   
 
 
 
If I get a value on ADR4 I am able to create the outputroot 
 
but if ADR4 is empty then iam not able to create the output tree.
 
 
can anyone give any suggestions on this.
 
Thanks in Advance. | 
   
 
 
Look at the available ESQL string manipulation functions . There is one that will help you with that.
 
 
Correction: Miscellaneous ESQL functions. | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | chaitu | 
		  
		    
			  
				 Posted: Mon May 16, 2016 6:02 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		   Voyager
 
 Joined: 15 Apr 2014 Posts: 89
  
  | 
		  
		    
			  
				Hi maurito,
 
 
Thanks for the reply.
 
 I used COALESCE function and now I am passing Null in place of empty field.
 
   
	| Code: | 
   
  
	
 
SET ADR4 =  COALESCE(CAST(InputRoot.DFDL.ECI_DEMO_ADR_LINE_1 AS CHARACTER),'NULL');
 
  | 
   
 
 | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | mayheminMQ | 
		  
		    
			  
				 Posted: Wed May 18, 2016 6:14 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		    Voyager
 
 Joined: 04 Sep 2012 Posts: 77 Location: UK beyond the meadows of RocknRoll 
  | 
		  
		    
			  
				The result of a concatenate using || will give out a NULL even if one value was NULL so I am not sure how did you solve this by using COALESCE? _________________ A Colorblind man may appear disadvantaged but he always sees more than just colors... | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | smdavies99 | 
		  
		    
			  
				 Posted: Wed May 18, 2016 6:25 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		    Jedi Council
 
 Joined: 10 Feb 2003 Posts: 6076 Location: Somewhere over the Rainbow this side of Never-never land. 
  | 
		  
		    
			  
				ADR1, ADR2 & ADR3 are set to explicit not derived values so they can never give a null result when concatenating them.
 
 
ADR4 is set using a concatenate that specified the string 'NULL' if the first part results in a real null value.
 
 
so 
 
 
OutputRoot.XMLNSC.Data = '00PNULL' 
 
 
OR 
 
 
OutputRoot.XMLNSC.Data = '00P' || The real value of  'InputRoot.DFDL.ECI_DEMO_ADR_LINE_1' cast to a CHAR; _________________ WMQ User since 1999
 
MQSI/WBI/WMB/'Thingy' User since 2002
 
Linux user since 1995
 
 
 
Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions. | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | 
		    
		   |