Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

NESTED FOR's help 1

Status
Not open for further replies.

julen

Programmer
Mar 26, 2006
27
ES
Hi everybody,

How can I do this in sql DB2?


FOR (i=0 to i< 10; i++)
FOR (j=0 to j< 10; i++)

....

Can you write me an example, please?

Thank you.
 
I think that you need to create an DB2 SQL stored procedure to use looping.
In that case you can use WHILE,FOR,REPEAT and LOOP.

The FOR approach just iterates over the rowset of a given SQL select.
In the WHILE approach you test a condition , perform an action, increment the counter and loop till the condition reads false.

Something like:
Code:
WHILE (i<10) DO 
       [SQL block]; 
   END WHILE;

Ties Blom

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top