|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
FOR ALL |
« View previous topic :: View next topic » |
Author |
Message
|
tammy |
Posted: Thu Apr 24, 2008 6:59 am Post subject: FOR ALL |
|
|
Newbie
Joined: 24 Apr 2008 Posts: 5
|
The "Writing ESQL" manual in the information center includes the following example:
FOR ALL Body.Invoice.Purchases."Item"[]
AS I (I.Quantity <= 50)
Whenever I enter it, the toolkit flags the ALL with an exclamation mark:
CREATE FILTER MODULE TFlow1_Filter
CREATE FUNCTION Main() RETURNS BOOLEAN
BEGIN
FOR ALL Body.Invoice.Purchases."Item"[]
AS I (I.Quantity <= 50)
RETURN TRUE;
END;
END MODULE;
The compilation fails reporting that there are errors in the project. If I comment out the two lines containing the FOR ALL and AS IS, everything is fine.
Why is the ALL keyword being flagged as a error? |
|
Back to top |
|
 |
Vitor |
Posted: Thu Apr 24, 2008 7:10 am Post subject: Re: FOR ALL |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
tammy wrote: |
The compilation fails reporting that there are errors in the project. If I comment out the two lines containing the FOR ALL and AS IS, everything is fine.
|
Pedantically, it's not AS IS, it's AS I as correctly shown in your code.
What is your code trying to achieve? Where does the return value from the FOR ALL get evaluated? _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
tammy |
Posted: Thu Apr 24, 2008 7:30 am Post subject: |
|
|
Newbie
Joined: 24 Apr 2008 Posts: 5
|
CREATE FILTER MODULE TFlow1_Filter
CREATE FUNCTION Main() RETURNS BOOLEAN
BEGIN
DECLARE X INTEGER;
SET X = 0;
FOR ALL Body.Invoice.Purchases."Item"[]
AS I (I.Quantity <= 50)
SET X = X + I.Quantity;
IF X > 0 THEN
RETURN TRUE;
END;
Sorry - put the latest version in (which is still being flagged as an error on the FOR ALL). The function should go through a structure and filter to TRUE if any Quantities were <= 50. I still don't understand why FOR ALL is being flagged as an error. |
|
Back to top |
|
 |
mgk |
Posted: Thu Apr 24, 2008 8:31 am Post subject: |
|
|
 Padawan
Joined: 31 Jul 2003 Posts: 1642
|
ESQL has a FOR Function and a FOR Statement. The Function (which is the syntax you are trying to use) can only be used as part of a larger expression. It cannot be used as a Statement (which you are trying to do). Instead the FOR Statement can be used if you want to perform Statements inside the FOR.
As the docs say:
Quote: |
"The FOR field function evaluates an expression and assigns a resulting value of TRUE, FALSE, or UNKNOWN" |
Where as the FOR Statement is used like this:
Code: |
FOR source AS Environment.SourceData.Folder[] DO
--statements using source
END FOR; |
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 |
|
 |
|
|
 |
|
Page 1 of 1 |
|
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
|
|
|
|