For-loop -iterative control, PL-SQL Programming

FOR-LOOP

While the number of iterations through a WHILE loop is unknown till the loop completes, then the number of iterations through a FOR loop is known before the loop is entered. The FOR loops iterate over a particular range of integers. The range is the part of an iteration scheme that is enclosed by the keywords FOR and LOOPS. A double dot (..) serve as the range operator. The syntax is as shown below:

FOR counter IN [REVERSE] lower_bound..higher_bound LOOP
sequence_of_statements
END LOOP;


The range is computed when the FOR loop is first entered and is never re-evaluated.



As the next illustration shows, the series of statements is executed once for each integer in the range. After each of the iteration, the loop counter is incremented.

FOR i IN 1..3 LOOP -- assign the values 1,2,3 to i
sequence_of_statements -- executes three times
END LOOP;


The following illustration shows that if the lower bound equals the higher bound, the series of the statements is executed once:

FOR i IN 3..3 LOOP -- assign the value 3 to i
sequence_of_statements -- executes one time
END LOOP;

Posted Date: 10/3/2012 5:57:10 AM | Location : United States







Related Discussions:- For-loop -iterative control, Assignment Help, Ask Question on For-loop -iterative control, Get Answer, Expert's Help, For-loop -iterative control Discussions

Write discussion on For-loop -iterative control
Your posts are moderated
Related Questions
Write a cursor to open an employee database and fetch the employee record whose age is greater than 45

Declarations in SQL Your program stores values in the variables and constants. As the program executes, the value of the variables can change, but the values constants cannot.


Need to change mysql query to PDO Project Description: I want someone to convert me 1 .php file that includes some sql/mysql stuff to PDO is a very small file. Skills requ

I have a Pascal Source file that needs to be compiled into a Service. In addition, there are various functions (Pascal Procedures I guess) that need to be created to Read and Write

Using COUNT The COUNT returns the number of elements that a collection presently contains. For instance, when a varray projects contains 15 elements, then the following IF con

Cursor Variables:   To execute the multi-row query, the Oracle opens an unnamed work region that stores the processing information. You can use an explicit cursor that names

We are seeking a freelance consultant that is familiar with Appgen applications. We require exporting all our data into a format appropriate for importing into SAP Business One. Pl

DBMS_OUTPUT: The Package DBMS_OUTPUT enables you to display output from the PL/SQL subprograms and blocks, that makes it easier to test and debug them. The procedure put_ line

LEVEL You use the LEVEL with the SELECT CONNECT BY statement to categorize rows from a database table into a tree structure. The LEVEL returns the level number of a node in a