|   | 
	 
  
    | 
RSS Feed - WebSphere MQ Support
 | 
RSS Feed - Message Broker Support
 |   
 
  
	     | 
	 | 
   
 
  
	|  Using FOR Statement with ANY or ALL produces syntax error | 
	« View previous topic :: View next topic »  | 
   
  
  	
	  
		
		
		  | Author | 
		  Message
		 |  
		
		  | Lone_Wanderer | 
		  
		    
			  
				 Posted: Wed Jan 03, 2024 8:17 am    Post subject: Using FOR Statement with ANY or ALL produces syntax error | 
				     | 
			   
			 
		   | 
		 
		
		   Newbie
 
 Joined: 16 Jan 2017 Posts: 9
  
  | 
		  
		    
			  
				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 | 
		  
		  	
		   | 
		 
		
		    | 
		 
		
		  | mgk | 
		  
		    
			  
				 Posted: Wed Jan 03, 2024 9:10 am    Post subject:  | 
				     | 
			   
			 
		   | 
		 
		
		    Padawan
 
 Joined: 31 Jul 2003 Posts: 1647
  
  | 
		  
		    
			  
				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 | 
		  
		  	
		   | 
		 
		
		    | 
		 
		
		  | Lone_Wanderer | 
		  
		    
			  
				 Posted: Wed Jan 03, 2024 9:45 am    Post subject:  | 
				     | 
			   
			 
		   | 
		 
		
		   Newbie
 
 Joined: 16 Jan 2017 Posts: 9
  
  | 
		  
		    
			  
				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 | 
		  
		  	
		   | 
		 
		
		    | 
		 
		
		  | 
		    
		   | 
		 
	   
	 | 
   
 
  
	     | 
	 | 
	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
  | 
  		 
	   
	 | 
   
 
  	 | 
	  |