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 statements within CASE

Post new topic  Reply to topic
 Multiple statements within CASE « View previous topic :: View next topic » 
Author Message
lung
PostPosted: Tue Oct 08, 2002 6:36 pm    Post subject: Multiple statements within CASE Reply with quote

Master

Joined: 27 Aug 2002
Posts: 291
Location: Malaysia

I am wondering if it is possible to have multiple ESQL statements within a CASE statement... For example, how can I make the following code work?


Code:
CASE TxnCode
 WHEN '0' THEN
 ...
 ... (multiple statements)
 WHEN '1' THEN
 ...
 ...
 ... (and so forth)
END;


Thanks!
_________________
lung
Back to top
View user's profile Send private message Send e-mail Yahoo Messenger MSN Messenger
lillo
PostPosted: Wed Oct 09, 2002 12:24 am    Post subject: Reply with quote

Master

Joined: 11 Sep 2001
Posts: 224

Have you tried the BEGIN and END statements?

Cheers,
_________________
Lillo
IBM Certified Specialist - WebSphere MQ
Back to top
View user's profile Send private message
lung
PostPosted: Wed Oct 09, 2002 9:51 pm    Post subject: Reply with quote

Master

Joined: 27 Aug 2002
Posts: 291
Location: Malaysia

Do they work? BEGIN and END? I couldn't try them out yet...

Anyway I'm having trouble with the following code...
Code:
CASE CurrentMonth
WHEN ’01’ THEN ’January’
WHEN ’02’ THEN ’February’
WHEN ’03’ THEN ’March’
WHEN ’04’ THEN ’April’
WHEN ’05’ THEN ’May’
WHEN ’06’ THEN ’June’
ELSE ’Second half of year’
END;

Keeps getting syntax error! And I actually copied that code from one of the IBM pdf files... Can anyone identify where is the error?


_________________
lung
Back to top
View user's profile Send private message Send e-mail Yahoo Messenger MSN Messenger
Nyusser
PostPosted: Thu Oct 10, 2002 1:31 am    Post subject: Reply with quote

Apprentice

Joined: 02 Jul 2002
Posts: 48

The CASE statement you use returns a value - which you have to deal with. For example:

Code:

DECLARE CurrentMonth CHAR;
DECLARE MonthStr CHAR;

SET CurrentMonth = '01';

SET MonthStr = CASE CurrentMonth
WHEN '01' THEN 'January'
WHEN '02' THEN 'February'
WHEN '03' THEN 'March'
WHEN '04' THEN 'April'
WHEN '05' THEN 'May'
WHEN '06' THEN 'June'
ELSE 'Second half of year';
END;


And variable CurrentMonth will have value 'January'.

- Nyusser
Back to top
View user's profile Send private message
lung
PostPosted: Thu Oct 10, 2002 5:11 pm    Post subject: Reply with quote

Master

Joined: 27 Aug 2002
Posts: 291
Location: Malaysia

Nyusser,

What if I doesn't want to SET MonthStr and want to do something else? (read my 1st post )

If 'CASE' only works when there is a 'SET' before it, then 'BEGIN' and 'END' clauses won't work with 'CASE', would they?

Thanks!
_________________
lung
Back to top
View user's profile Send private message Send e-mail Yahoo Messenger MSN Messenger
Nyusser
PostPosted: Thu Oct 10, 2002 10:10 pm    Post subject: Reply with quote

Apprentice

Joined: 02 Jul 2002
Posts: 48

According to ESQL Reference (CSD2) CASE always returns a value, which means a result-value (e.g. THEN 'January') or result-expression (e.g. THEN SUBSTRING(CurrentMonth FROM 2 FOR 1) ) after WHEN. This means that ESQL's CASE function is not like CASE functions in other programming languages...

I guess, that the only way to execute several statements after WHEN is to call user-defined functions, which return appropriate values. BEGIN and END clauses probably won't work.

- Nyusser
Back to top
View user's profile Send private message
lung
PostPosted: Fri Oct 11, 2002 4:47 pm    Post subject: Reply with quote

Master

Joined: 27 Aug 2002
Posts: 291
Location: Malaysia

Seems like the CREATE FUNCTION statement will also always return a value (a result-value)...

There seems to be something called CREATE PROCEDURE which may work (since it doesn't return a result-value) and something called a COMPOUND statement... Anyone has any idea how the COMPOUND statement works? I can't find any sample codes in the docs.

But then again the CREATE PROCEDURE statement will only work with the CALL statement, which doesn't work with the CASE statement...

Is there really no method in ESQL to make multiple IF-ELSE statements simpler?
_________________
lung
Back to top
View user's profile Send private message Send e-mail Yahoo Messenger MSN Messenger
lillo
PostPosted: Sat Oct 12, 2002 4:41 am    Post subject: Reply with quote

Master

Joined: 11 Sep 2001
Posts: 224

Quote:
Is there really no method in ESQL to make multiple IF-ELSE statements simpler?


ELSIF functionality is implemented in CSD3. I really necessary improvement to ESQL.

Cheers
_________________
Lillo
IBM Certified Specialist - WebSphere MQ
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 statements within CASE
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.