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 » Issue with 'String followed by space' in IF condition - ESQL

Post new topic  Reply to topic
 Issue with 'String followed by space' in IF condition - ESQL « View previous topic :: View next topic » 
Author Message
rajbuddha
PostPosted: Tue Apr 24, 2012 11:03 pm    Post subject: Issue with 'String followed by space' in IF condition - ESQL Reply with quote

Apprentice

Joined: 02 Aug 2011
Posts: 47
Location: chennai

I am facing the below issue in WMB6.0 as well as WMB8.0 :

My requirement is to do soemthing like :

IF InputRoot.XMLNSC.A.B = 'XYZ'
THEN
SET OutputRoot.XMLNSC.C.D = 'Hi';
ELSE
SET OutputRoot.XMLNSC.C.D = 'Bye';
END IF;

When my input contains a value of 'XYZ ', i.e., XYZ followed by spaces, the same is being treated equivalent to just 'XYZ' (without a space) and I am receiving a 'Hi' instead of 'Bye' in the output.

Please note that the same behaviour is observed while using CASE statement as well.

Has anyone faced similar issues before ?

Any inputs that you could provide on the above would help.

Thanks !
_________________
-----------

Raju Buddha

Never Wait for your 2nd Opportunity..!Becoz it may be harder than the 1st One...
Back to top
View user's profile Send private message Send e-mail
zpat
PostPosted: Tue Apr 24, 2012 11:20 pm    Post subject: Reply with quote

Jedi Council

Joined: 19 May 2001
Posts: 5866
Location: UK

It's fairly standard, in flexible languages, when different length strings are being compared to automatically pad the shorter one on the right with blanks.

So make sure the strings the same length using LEFT or SUBSTR or whatever and a length value.
Back to top
View user's profile Send private message
mqjeff
PostPosted: Wed Apr 25, 2012 2:29 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

Code:
if TRIM(InputRoot.XMLNSC.A.B) = 'XYZ'
Back to top
View user's profile Send private message
sree4vit
PostPosted: Wed Apr 25, 2012 2:56 am    Post subject: Reply with quote

Novice

Joined: 05 Aug 2010
Posts: 21

Quote:
DECLARE Counter CHARACTER LENGTH (InputRoot.XMLNSC.A.B);
IF Counter = 3 AND InputRoot.XMLNSC.A.B = 'XYZ'
THEN
SET OutputRoot.XMLNSC.C.D = 'Hi';
ELSE
SET OutputRoot.XMLNSC.C.D = 'Bye';
END IF;


- try this
Back to top
View user's profile Send private message
mgk
PostPosted: Wed Apr 25, 2012 4:33 am    Post subject: Reply with quote

Padawan

Joined: 31 Jul 2003
Posts: 1642

This behaviour with string comparison is by design. From the infocenter:

Quote:
Trailing blanks are regarded as insignificant in character comparisons. Thus if you want to ensure that two strings are truly equal you need to compare both the strings themselves and their lengths. For example:

Code:
'ABC  ' is equal to 'ABC'


Kind Regards,
_________________
MGK
The postings I make on this site are my own and don't necessarily represent IBM's positions, strategies or opinions.
Back to top
View user's profile Send private message
Vitor
PostPosted: Wed Apr 25, 2012 5:10 am    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

zpat wrote:
It's fairly standard, in flexible languages, when different length strings are being compared to automatically pad the shorter one on the right with blanks.




Not only flexible languages. Most variants of COBOL do this too....

I'm surprised you've not noticed this in your other coding experiences. As my most worthy & knowledgeable associate (who I beleve is giving a REST in Vegas on Friday the 4th!) points out this is documented & you need something like the code snippets posted to deal with it.
_________________
Honesty is the best policy.
Insanity is the best defence.
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 » Issue with 'String followed by space' in IF condition - ESQL
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.