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 » Using FOR Statement with ANY or ALL produces syntax error

Post new topic  Reply to topic
 Using FOR Statement with ANY or ALL produces syntax error « View previous topic :: View next topic » 
Author Message
Lone_Wanderer
PostPosted: Wed Jan 03, 2024 8:17 am    Post subject: Using FOR Statement with ANY or ALL produces syntax error Reply with quote

Newbie

Joined: 16 Jan 2017
Posts: 8

Following example code:

Code:
CREATE COMPUTE MODULE testy
   CREATE FUNCTION Main() RETURNS BOOLEAN
   BEGIN
   FOR ALL Body.Invoice.Purchases."Item"[]
       AS I (I.Quantity <= 50)
   END FOR;
   END;
END MODULE;


Is producing following exception:
Syntax error. Valid options include: .NET IDENTIFIER SIMPLE_FUNCTION

I took the code from IBM directly,
https://www.ibm.com/docs/en/app-connect/12.0?topic=content-accessing-unknown-multiple-occurrences-element

I don't understand what the error is. I'm using the code as is.

(Yes, for all intents and purposes the code is incomplete and achieves nothing, I reduced it to deomnstrate the syntax error itself. Even if the code is the part of a bigger code base, same error persists)

ACE 12.0.8.0

[/b]
Back to top
View user's profile Send private message
mgk
PostPosted: Wed Jan 03, 2024 9:10 am    Post subject: Reply with quote

Padawan

Joined: 31 Jul 2003
Posts: 1638

Hi, so the example is correct but confusing.

In ESQL there is a FOR STATEMENT:
https://www.ibm.com/docs/en/app-connect/12.0?topic=statements-statement

And there is a FOR FUNCTION:
https://www.ibm.com/docs/en/app-connect/12.0?topic=functions-function

The code you posted mixed them up - it uses the FOR ALL syntax which is part of the FOR FUNCTION but then has a END FOR; which is part of a FOR STATEMENT and this is why an error is shown in the toolkit.

The docs example you linked to is using the FOR FUNCTION, but does not make that clear. It needs to be included within a statement to be valid in
the toolkit, For example this should parse correctly for you:

Code:
SET OutputRoot.JSON.Data.Result = FOR ANY InputRoot.JSON.Invoice.Purchases."Item"[]
       AS I (I.Quantity <= 50);


However, personally I would write these on one line to avoid confusion:
Code:
SET OutputRoot.JSON.Data.Result = FOR ANY InputRoot.JSON.Invoice.Purchases."Item"[] AS I (I.Title = 'The XML Companion');


I do think the example could be improved to make this clear and I will request that it is updated.

I hope this helps and makes sense...
_________________
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
View user's profile Send private message
Lone_Wanderer
PostPosted: Wed Jan 03, 2024 9:45 am    Post subject: Reply with quote

Newbie

Joined: 16 Jan 2017
Posts: 8

I was not familiar with FOR FUNCTION. Now it's all much more clear and the esql compiles

Thank you kindly for quick response.
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 » Using FOR Statement with ANY or ALL produces syntax error
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.