Exforsys.com
 
Home Tutorials Oracle 9i
 

Tutorial 9 : Oracle 9i: PL/SQL Control Structures

 

Tutorial 9 : Oracle 9i: PL/SQL Control Structures - Page 2

Page 2 of 2





WHILE-LOOP


This is similar to LOOP. A condition placed between WHILE and LOOP is evaluated before each iteration. If the condition evaluates to TRUE the statements are executed and the control resumes at the top of the LOOP. If the condition evaluates to FALSE or NULL then control comes out of the loop.




FOR – LOOP:


The FOR – LOOP is used to repeatedly execute a set of statements for certain number of times specified by a starting number and an ending number. The variable value starts at the starting value given and increments by 1(default and can not be changed) with each iteration. The iteration stops when the variable value reaches end value specified.


Syntax:



FOR IN


LOOP


Statements


END LOOP;






Sequential Control Statements



The GOTO statement is used for doing unconditional branching to a named label. Its frequent usage is not recommended. We should have at least one executable statement following the label. GOTO statements can some time result in complex, unstructured code making it difficult to understand.




Points To be remembered while working with GOTO:


  • A statement, at least NULL statement, must follow every GOTO statement
  • A GOTO statement can branch to enclosing block from the current block
  • A GOTO statement cannot branch from one IF statement clause to another.
  • A GOTO statement cannot branch from an enclosing block into a sub-block.
  • A GOTO statement cannot branch out of a subprogram.
  • A GOTO cannot branch from an exception handler to current block. But it can branch from the exception handler to an enclosing block


First Page: Tutorial 9 : Oracle 9i: PL/SQL Control Structures


Read Next: Tutorial 10: Oracle 9i : Cursors



 

 

Comments


Narendra Reddy said:

  I have completed working with control structures thoroughly....
July 20, 2007, 2:34 am

Jimbo888 said:

  Can i have sub-loops in PL/SQL? like a loop inside a LOOP??
December 14, 2008, 11:04 am

raghu said:

  this is best tutorial...in real
best..........its great
December 19, 2008, 2:13 pm

Post Your Comment:

Members Please Login
Your Name:*
e-mail ID:(required for notification)*
Image Verification: 
 
 Subscribe    

Sponsored Links

 

Subscribe via RSS


Get Daily Updates via Subscribe to Exforsys Free Training via email


Get Latest Free Training Updates delivered directly to your Inbox...

Enter your email address:


 

Subscribe to Exforsys Free Training via RSS
 

 
Partners -  Privacy and Legal Policy -  Site News -  Contact   Sitemap  

Copyright © 2000 - 2009 exforsys.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape