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 » Nested IF Statements

Post new topic  Reply to topic
 Nested IF Statements « View previous topic :: View next topic » 
Author Message
Gary Ellwood
PostPosted: Thu Jul 11, 2002 5:54 am    Post subject: Nested IF Statements Reply with quote

Novice

Joined: 17 Apr 2002
Posts: 12

Hello (again)

Are nested IF statements allowable in ESQL, and if so what is the correct syntax? I have written the following ESQL, which presently sends the dataflow engine into a loop!! I can't seem to find anything helpful in the documentation. It is further complicated by the fact that the nested IF occurs inside a WHILE loop.

DECLARE I INTEGER;
DECLARE TEST CHARACTER;
SET I=1;

WHILE I <= CARDINALITY (InputBody.ManOrder.ReportPOItem[]) DO

IF InputBody.ManOrder.ReportPOItem[I].NegVariance > 0 THEN
IF
((InputBody.ManOrder.ReportPOItem[I].NegVariance) > (THE (SELECT ITEM Threshold.NegativeThreshold FROM
Database.Threshold
WHERE Threshold.ProductId = InputBody.ManOrder.ReportPOItem[I].ManProductId AND
Threshold.EventId = 1)))
THEN
CREATE FIELD OutputRoot.XML.ManOrder.ReportPOItem[I].RaiseEvent;
CREATE FIELD OutputRoot.XML.ManOrder.ReportPOItem[I].EventType;
CREATE FIELD OutputRoot.XML.ManOrder.ReportPOItem[I].NegativeThreshold;
CREATE FIELD OutputRoot.XML.ManOrder.ReportPOItem[I].NegativeDesc;
CREATE FIELD OutputRoot.XML.ManOrder.ReportPOItem[I].Status;
SET OutputRoot.XML.ManOrder.ReportPOItem[I].Status = THE (SELECT ITEM Threshold.Status FROM
Database.Threshold
WHERE Threshold.ProductId = InputBody.ManOrder.ReportPOItem[I].ManProductId AND
Threshold.EventId = 1);
SET OutputRoot.XML.ManOrder.ReportPOItem[I].NegativeThreshold = THE (SELECT ITEM Threshold.NegativeThreshold FROM
Database.Threshold
WHERE Threshold.ProductId = InputBody.ManOrder.ReportPOItem[I].ManProductId AND
Threshold.EventId = 1);
SET OutputRoot.XML.ManOrder.ReportPOItem[I].NegativeDesc = THE (SELECT ITEM Threshold.NegativeDesc FROM
Database.Threshold
WHERE Threshold.ProductId = InputBody.ManOrder.ReportPOItem[I].ManProductId AND
Threshold.EventId = 1);
SET OutputRoot.XML.ManOrder.ReportPOItem[I].RaiseEvent = 'Yes';
SET OutputRoot.XML.ManOrder.ReportPOItem[I].EventType = 'Negative';
ELSE
CREATE FIELD OutputRoot.XML.ManOrder.ReportPOItem[I].RaiseEvent;
SET OutputRoot.XML.ManOrder.ReportPOItem[I].RaiseEvent = 'No';
END IF;
ELSE
IF
((InputBody.ManOrder.ReportPOItem[I].PosVariance) > (THE (SELECT ITEM Threshold.PositiveThreshold FROM
Database.Threshold
WHERE Threshold.ProductId = InputBody.ManOrder.ReportPOItem[I].ManProductId AND
Threshold.EventId = 1)))
THEN
CREATE FIELD OutputRoot.XML.ManOrder.ReportPOItem[I].EventId;
CREATE FIELD OutputRoot.XML.ManOrder.ReportPOItem[I].RaiseEvent;
CREATE FIELD OutputRoot.XML.ManOrder.ReportPOItem[I].EventType;
CREATE FIELD OutputRoot.XML.ManOrder.ReportPOItem[I].PositiveThreshold;
CREATE FIELD OutputRoot.XML.ManOrder.ReportPOItem[I].PositiveDesc;
CREATE FIELD OutputRoot.XML.ManOrder.ReportPOItem[I].Status;

SET OutputRoot.XML.ManOrder.ReportPOItem[I].Status = THE (SELECT ITEM Threshold.Status FROM
Database.Threshold
WHERE Threshold.ProductId = InputBody.ManOrder.ReportPOItem[I].ManProductId AND
Threshold.EventId = 1);
SET OutputRoot.XML.ManOrder.ReportPOItem[I].PositiveThreshold = THE (SELECT ITEM Threshold.PositiveThreshold FROM
Database.Threshold
WHERE Threshold.ProductId = InputBody.ManOrder.ReportPOItem[I].ManProductId AND
Threshold.EventId = 1);
SET OutputRoot.XML.ManOrder.ReportPOItem[I].PositiveDesc = THE (SELECT ITEM Threshold.PositiveDesc FROM
Database.Threshold
WHERE Threshold.ProductId = InputBody.ManOrder.ReportPOItem[I].ManProductId AND
Threshold.EventId = 1);
SET OutputRoot.XML.ManOrder.ReportPOItem[I].EventId = 1;
SET OutputRoot.XML.ManOrder.ReportPOItem[I].RaiseEvent = 'Yes';
SET OutputRoot.XML.ManOrder.ReportPOItem[I].EventType = 'Positive';
ELSE
CREATE FIELD OutputRoot.XML.ManOrder.ReportPOItem[I].RaiseEvent;
SET OutputRoot.XML.ManOrder.ReportPOItem[I].RaiseEvent = 'No';
END IF;

END IF;
END WHILE;
Back to top
View user's profile Send private message Send e-mail
TorpedoSTu
PostPosted: Thu Jul 11, 2002 6:48 am    Post subject: Reply with quote

Acolyte

Joined: 14 Nov 2001
Posts: 73

The nesting is fine, but you don't seem to be incrementing I !!! - Therefore the infinite loop

Regs

Stuart
Back to top
View user's profile Send private message Send e-mail
Gary Ellwood
PostPosted: Thu Jul 11, 2002 9:02 am    Post subject: Reply with quote

Novice

Joined: 17 Apr 2002
Posts: 12

Ooooops. Thanks for that........I was obviously looking too hard and missing the obvious!!!
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Nested IF Statements
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.