Posted: Thu Jul 11, 2002 5:54 am Post subject: Nested IF Statements
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;
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