| Author | 
		  Message
		 | 
		
		  | fenway_frank | 
		  
		    
			  
				 Posted: Wed Aug 14, 2013 2:30 pm    Post subject: ESQL single quote literals | 
				     | 
			   
			 
		   | 
		
		
		    Apprentice
 
 Joined: 21 Oct 2011 Posts: 43 Location: Boston, MA USA 
  | 
		  
		    
			  
				hello all.
 
attempting to concatenate the value of a local variable with single quotes and my efforts have proven futile thus far.   btw, this is broker v8002 if you were interested.
 
 
here's my desired output:
 
[gep63_consumerIdentifier='AX001074']
 
 
 
the value of consumerIdentifier (in this case AX001074) will change per request and is stored in a local CHAR variable.  i need to concat single quotes around the value like this.. 'AX001074'
 
 
below is the ESQL code.  
 
 
****************************
 
DECLARE consumerId CHAR UCASE(InputRoot.SOAP.Header.scc:ServiceCallContext.scc:From);
 
		
 
 
DECLARE part1 CHAR '[gep63_consumerIdentifier=';
 
 
DECLARE part2 CHAR '' || consumerId || '' || ']'; 
 
			
 
****************************
 
 
as currently coded, variable part2 returns AX001074]  without single quotes around consumerId's value.
 
 
i've tried several approaches but can't escape the single quote properly.
 
 
for example :
 
DECLARE part2 CHAR ''' || consumerId || ''' || ']'; 
 
 
returns '|| consumerId ||']
 
 
thoughts? | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | mqjeff | 
		  
		    
			  
				 Posted: Wed Aug 14, 2013 2:38 pm    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		   Grand Master
 
 Joined: 25 Jun 2008 Posts: 17447
  
  | 
		  
		    
			  
				I think you need 4 single-quotes to get one single-quote.
 
 
Because you need to create a constant string that consists of a single quote.  When using a single quote inside a constant string, you must put in two single quotes ('').  You must then surround those two single quotes with a pair of single quotes ('literalvalue').  
 
 
So '<single-quote>' is ''''. | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | mqsiuser | 
		  
		    
			  
				 Posted: Wed Aug 14, 2013 3:45 pm    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		    Yatiri
 
 Joined: 15 Apr 2008 Posts: 637 Location: Germany 
  | 
		  
		    
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | fjb_saper | 
		  
		    
			  
				 Posted: Wed Aug 14, 2013 8:37 pm    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		    Grand High Poobah
 
 Joined: 18 Nov 2003 Posts: 20768 Location: LI,NY 
  | 
		  
		    
			  
				Looks at me like you're overly complicating things...
 
so you want the end result to be
 
Value of variable gep63_consumerIdentifier (field or attribute) is AX001074
 
if that is the case you should have a construct like this
 
   
	| Code: | 
   
  
	SET part1 = 'gep63_consumerIdentifier';
 
SET part2 = 'AX001074';
 
SET ref.{part1} = part2; | 
   
 
 
 
If for whatever reason you need to build the literal including the ] you should use assuming the same part 1 and 2 from the above example
 
   
	| Code: | 
   
  
	set value='[' || part1 || '=''' || part2 || ''']';
 
-- or 
 
SET part1='[gep63_consumerIdentifier=';
 
SET part2='''' || consumerId || ''']'; --text quote+escaped quote + text quote +concat+variable+concat + text quote +escaped quote + bracket + text quote
 
SET variable = part1 || part2;
 
  | 
   
 
 
I'd like you to also consider how you'd want to handle the case where consumerId is empty or is null...
 
Have fun   _________________ MQ & Broker admin | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | fenway_frank | 
		  
		    
			  
				 Posted: Thu Aug 15, 2013 5:54 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		    Apprentice
 
 Joined: 21 Oct 2011 Posts: 43 Location: Boston, MA USA 
  | 
		  
		    
			  
				thanks to all for prompt feedback.  your suggestion to include four single quotes worked like a charm.
 
 
@fjb_saper :  yes, i am checking for empty/null condition prior to this string concat operation... did not copy that stuff into the code snippet i provided. | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | kimbert | 
		  
		    
			  
				 Posted: Thu Aug 15, 2013 10:47 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		    Jedi Council
 
 Joined: 29 Jul 2003 Posts: 5543 Location: Southampton 
  | 
		  
		    
			  
				
   
	| Quote: | 
   
  
	here's my desired output: 
 
[gep63_consumerIdentifier='AX001074']  | 
   
 
Looks like a data format to me. So a Data Format Description Language could be useful  
 
 
Don't worry - I do understand that for a single field, using DFDL might be overkill. But if you are building up several fields like this in a structure then you definitely should be looking at using DFDL. _________________ Before you criticize someone, walk a mile in their shoes. That way you're a mile away, and you have their shoes too. | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | Simbu | 
		  
		    
			  
				 Posted: Thu Aug 15, 2013 10:12 pm    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		    Master
 
 Joined: 17 Jun 2011 Posts: 289 Location: Tamil Nadu, India 
  | 
		  
		    
			  
				
   
	| kimbert wrote: | 
   
  
	| if you are building up several fields like this in a structure then you definitely should be looking at using DFDL. | 
   
 
 
 
Thanks for the suggestion kimbert. I tried this scenario and implemented using DFDL. | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | 
		    
		   |