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 » Multiple Choices for a CASE when

Post new topic  Reply to topic
 Multiple Choices for a CASE when « View previous topic :: View next topic » 
Author Message
smdavies99
PostPosted: Wed Aug 22, 2012 2:42 am    Post subject: Multiple Choices for a CASE when Reply with quote

Jedi Council

Joined: 10 Feb 2003
Posts: 6076
Location: Somewhere over the Rainbow this side of Never-never land.

If have a siruation the there are some 50 different possible (and growing) values for a field.
normally, I'd put a case statement like the following
Code:

 case cItem
  when 'Type1' then
   ...
  when 'Type2' then
  ...
 etc
  end case;


In the 50 values there are some 15 common actions I need to take. In theory something like this would be ideal
Code:

 case cItem
  when 'Type1' or 'Type33' or 'Type49'  then
   ...
  when 'Type2' or 'Type16' or 'Type19' or 'Type20' then
  ...
 etc
  end case;

This compiles (on 7.0.0.4) but fails to deploy.
Quote:

BIP2427E: (.SITREP_Master_Compute.ProcessMsg, 122.15) : The left operand of 'OR' operator is not a boolean expression.

The left operand of this operator must be a boolean expression.

Correct the syntax of your ESQL expression in node '.SITREP_Master_Compute.ProcessMsg', around line and column '122.15', then redeploy the message flow.

Is what I want to do possible. The infocentre seems to say so
'WHEN--Expression--THEN--Statements'
but I'm not so sure.

If this isn't possible then I'll just have to bite the bullet and case each one individually. I'd really prefer to use a CASE rather than an IF then ... elseif etc as the CASE option is IMHO far more maintainable.
_________________
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
View user's profile Send private message
Vitor
PostPosted: Wed Aug 22, 2012 2:52 am    Post subject: Reply with quote

Grand High Poobah

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

Does

Code:

case
  when cItem= 'Type1' or cItem = 'Type33' or cItem = 'Type49'  then
   ...
 etc
  end case;


work?
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
McueMart
PostPosted: Wed Aug 22, 2012 2:52 am    Post subject: Reply with quote

Chevalier

Joined: 29 Nov 2011
Posts: 490
Location: UK...somewhere

Code:

case
  when  (cItem = 'Type1')  or (cItem =  'Type33') or (cItem = 'Type49')  then
   ...
  when (cItem ='Type2') or (cItem = 'Type16') or (cItem = 'Type19') or (cItem = 'Type20') then
  ...
 etc
  end case;


That should work!
Back to top
View user's profile Send private message
McueMart
PostPosted: Wed Aug 22, 2012 2:53 am    Post subject: Reply with quote

Chevalier

Joined: 29 Nov 2011
Posts: 490
Location: UK...somewhere

@Vitor - you too quick!
Back to top
View user's profile Send private message
mqjeff
PostPosted: Wed Aug 22, 2012 4:11 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

McueMart wrote:
@Vitor - you too quick!

I was getting coffee.
Back to top
View user's profile Send private message
Vitor
PostPosted: Wed Aug 22, 2012 4:31 am    Post subject: Reply with quote

Grand High Poobah

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

mqjeff wrote:
McueMart wrote:
@Vitor - you too quick!

I was getting coffee.


An activity you perform marginally less often than breathing.

I was eating breakfast - what's your point?
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
smdavies99
PostPosted: Wed Aug 22, 2012 4:49 am    Post subject: Reply with quote

Jedi Council

Joined: 10 Feb 2003
Posts: 6076
Location: Somewhere over the Rainbow this side of Never-never land.

Thanks for the replies. IMHO the result is only slightly more readable that if..the...else when you compare it to
Code:

 if PLUGGH in ( 'Gold', 'Silver', 'Blood', 'Sweat', 'Tears' ) then
 ...
 end if;

now if 'CASE' supported the 'IN' clause then I'd be happy.

and these goes that squadron of Vulcans flying taking off from Farnborough...
_________________
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
View user's profile Send private message
Vitor
PostPosted: Wed Aug 22, 2012 5:14 am    Post subject: Reply with quote

Grand High Poobah

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

smdavies99 wrote:
now if 'CASE' supported the 'IN' clause then I'd be happy.


Doesn't it?
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
Vitor
PostPosted: Wed Aug 22, 2012 5:23 am    Post subject: Reply with quote

Grand High Poobah

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

Vitor wrote:
smdavies99 wrote:
now if 'CASE' supported the 'IN' clause then I'd be happy.


Doesn't it?


Yes it does.

(WMBv7.0.0.4, code as indicated above, extensively tested with 1 scenario....)
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
mgk
PostPosted: Wed Aug 22, 2012 5:30 am    Post subject: Reply with quote

Padawan

Joined: 31 Jul 2003
Posts: 1642

Quote:
now if 'CASE' supported the 'IN' clause then I'd be happy.


It does if you use the 'Searched CASE' statement:
Code:

DECLARE cItem CHARACTER 'Type49';
      
CASE 
  WHEN cItem IN ('Type1', 'Type33', 'Type49') THEN
    SET OutputRoot.XMLNSC.Test.Result = 'case 1';
  WHEN cItem IN ('Type2', 'Type16', 'Type19', 'Type20') THEN
    SET OutputRoot.XMLNSC.Test.Result = 'case 2';
END CASE;


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
mqjeff
PostPosted: Wed Aug 22, 2012 5:33 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

Vitor wrote:
mqjeff wrote:
McueMart wrote:
@Vitor - you too quick!

I was getting coffee.


An activity you perform marginally less often than breathing.

I was eating breakfast - what's your point?


If I kept coffee in the house, I would not leave the house.
Back to top
View user's profile Send private message
smdavies99
PostPosted: Wed Aug 22, 2012 6:27 am    Post subject: Reply with quote

Jedi Council

Joined: 10 Feb 2003
Posts: 6076
Location: Somewhere over the Rainbow this side of Never-never land.

Typical, that must have been the one combination I failed to try.

Thanks.
_________________
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
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 » Multiple Choices for a CASE when
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.