| Author | 
		  Message
		 | 
		
		  | vijayakumar | 
		  
		    
			  
				 Posted: Wed Nov 28, 2012 2:50 am    Post subject: How to Comes out f the FOR loop | 
				     | 
			   
			 
		   | 
		
		
		   Centurion
 
 Joined: 01 Aug 2010 Posts: 101
  
  | 
		  
		    
			  
				I m using the FOR Looop and inside that i am using IF loop. If a particular condition matches, i need to comes out of the both IF and FOR loop.
 
 
How to do this? | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | marko.pitkanen | 
		  
		    
			  
				 Posted: Wed Nov 28, 2012 3:01 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		    Chevalier
 
 Joined: 23 Jul 2008 Posts: 440 Location: Jamsa, Finland 
  | 
		  
		    
			  
				Hi,
 
 
I assume that you are using ESQL. At which version your broker runs?
 
Did you for example try to find answer from InfoCenter?
 
 
--
 
Marko | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | mqsiuser | 
		  
		    
			  
				 Posted: Wed Nov 28, 2012 3:20 am    Post subject: Re: How to Comes out f the FOR loop | 
				     | 
			   
			 
		   | 
		
		
		    Yatiri
 
 Joined: 15 Apr 2008 Posts: 637 Location: Germany 
  | 
		  
		    
			  
				
   
	| vijayakumar wrote: | 
   
  
	I m using the FOR Looop and inside that i am using IF loop. If a particular condition matches, i need to comes out of the both IF and FOR loop.
 
 
How to do this? | 
   
 
 
 
Set the condition(s) so that the IF(-statement) and FOR(-loop) stop.
 
 
e.g. 
 
You FOR-loop is from x=1 to 10:    SET x = 11;
 
Your IF checks for IF a != "xyz":     SET a = "xyz";
 
 
Or use a WHILE-loop _________________ Just use REFERENCEs | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | polydegmon | 
		  
		    
			  
				 Posted: Wed Nov 28, 2012 5:12 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		   Novice
 
 Joined: 07 Oct 2011 Posts: 11
  
  | 
		  
		    
			  
				You can use the LEAVE statement with a WHILE loop, but it can't be used with a FOR loop.
 
 
   
	| Code: | 
   
  
	
 
Check : WHILE <Condition>
 
            
 
   IF <Condition> THEN
 
      LEAVE Check;         
 
   END IF;
 
   
 
END WHILE;
 
 | 
   
 
 
 
There's no way I know of to jump out of a FOR AS loop, it will itterate through to the end regardless of what statements you put inside it to limit processing. | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | mgk | 
		  
		    
			  
				 Posted: Wed Nov 28, 2012 8:11 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		    Padawan
 
 Joined: 31 Jul 2003 Posts: 1647
  
  | 
		  
		    
			  
				
   
	| Quote: | 
   
  
	| There's no way I know of to jump out of a FOR AS loop | 
   
 
 
 
If you wrap the FOR in a BEGIN ... END block, this block can also have a label and you can then LEAVE to the outer BEGIN .. END block...
 
 
 
Kind 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 | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | 
		    
		   |