ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » ESQL single quote literals

Post new topic  Reply to topic
 ESQL single quote literals « View previous topic :: View next topic » 
Author Message
fenway_frank
PostPosted: Wed Aug 14, 2013 2:30 pm    Post subject: ESQL single quote literals Reply with quote

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
View user's profile Send private message
mqjeff
PostPosted: Wed Aug 14, 2013 2:38 pm    Post subject: Reply with quote

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
View user's profile Send private message
mqsiuser
PostPosted: Wed Aug 14, 2013 3:45 pm    Post subject: Reply with quote

Yatiri

Joined: 15 Apr 2008
Posts: 637
Location: Germany

http://www.mqseries.net/phpBB/viewtopic.php?p=254310

http://www.mqseries.net/phpBB2/viewtopic.php?t=62058
_________________
Just use REFERENCEs
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Wed Aug 14, 2013 8:37 pm    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20756
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
View user's profile Send private message Send e-mail
fenway_frank
PostPosted: Thu Aug 15, 2013 5:54 am    Post subject: Reply with quote

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
View user's profile Send private message
kimbert
PostPosted: Thu Aug 15, 2013 10:47 am    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
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
View user's profile Send private message
Simbu
PostPosted: Thu Aug 15, 2013 10:12 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » ESQL single quote literals
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.