You can loop through statements with LOOP, WHILE, and REPEAT:
- Using the LOOP statement: LOOP allows you to execute a statement repeatedly. If you don't specifically terminate a LOOP statement, it can run infinitely. The following shows you an example of the LOOP syntax:
[beginlabel:] LOOP sql statements END LOOP [endlabel];
beginlabel and endlabel are optional, and you can name them whatever makes sense for the loop. You use the label when executing an ITERATE or LEAVE statement. The SQL statements will execute once, each time LOOP executes. You can terminate a LOOP with either a LEAVE or RETURN statement. You should use a LOOP statement when you aren't certain how many times it may need to ...