loop
SQL/PL
Loop statement
Syntax
loop_stmt: [ label_name:] LOOP statement_list END LOOP [ label_name]
Description
The LOOP statement will repeatedly execute statement_list until a LEAVE (or RETURN in a function) statement is executed. If an END LOOP specifies label_name then an identical opening label_name: must be specified as well.
Example
find_author: loop fetch authors into author_row; if end_of_search = true then leave find_author; end if; if author_row.yr_born between decade and decade + 9 then set numfound = numfound + 1; select numfound, author_row.full_name, author_row.yr_born; end if;end loop;
See Also