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 » CASE Statement -- 2 Conditions

Post new topic  Reply to topic
 CASE Statement -- 2 Conditions « View previous topic :: View next topic » 
Author Message
wmqiguy
PostPosted: Tue Feb 15, 2005 2:07 pm    Post subject: CASE Statement -- 2 Conditions Reply with quote

Centurion

Joined: 09 Oct 2002
Posts: 145
Location: Florida

Have a question about the CASE statement. Here is the example from the ESQL Reference:

Code:
CASE size
     WHEN 'A' THEN
          SET description = ’small’;
     WHEN 'B' THEN
          SET description = ’medium’;
     WHEN 'C' THEN
          SET description = ’large’;
     ELSE SET description = ’unknown’; 
          CALL handleError();
END CASE;


WBIMB is spitting when I try to evaluate two values such as:

CASE size
WHEN 'A' OR 'Z' THEN
SET description = ’small’;

WHEN 'B' THEN
SET description = ’medium’;
WHEN 'C' THEN
SET description = ’large’;
ELSE SET description = ’unknown’;
CALL handleError();
END CASE;

Do I have the syntax screwed up or am I reduced to having 2 WHEN statements with the same lines executed?

Thanks in advance.
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Tue Feb 15, 2005 2:44 pm    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

You need to switch which CASE you are using.

The way you have it written, it is comparing size against ('A' OR 'Z') - which is a boolean.

Try
Code:

SET description = CASE
   WHEN size = 'A' or size = 'Z' then 'small'
    WHEN size = 'B" then 'medium'
 END;

for example
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
wmqiguy
PostPosted: Tue Feb 15, 2005 6:17 pm    Post subject: Reply with quote

Centurion

Joined: 09 Oct 2002
Posts: 145
Location: Florida

Thanks, but that is not quite what I want.

The example was actually a very simple version and my pseudocode would actually be something along the lines of:

Code:
CASE InputRoot.MRM.Order.Type
     WHEN 'DaysExceededHold' or 'CreditHold' THEN
          Do a whole bunch of stuff in a database;
     WHEN 'Clear' THEN
          Log the message and then quit.
     WHEN 'Other' THEN
          Do different stuff in a database
     WHEN lots of other possibilities
END CASE


There is a LOT of code for each possible case. From what you've said here, the best option is to just have a WHEN statement for each Order Type and then just wrap the logic in a function to be called for each of the WHEN clauses.

Thanks.
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Wed Feb 16, 2005 5:16 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

It's always better to have long segments of code put into proper procedures or modules, yes.

I believe that the ESQL case will support "fall through", but I haven't tried it.

Something like
Code:
WHEN 'A' THEN
WHEN 'Z' THEN
     do stuff

_________________
I am *not* the model of the modern major general.
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 » CASE Statement -- 2 Conditions
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.