Firebird Documentation Index → Firebird 1.5 Language Ref. Update → PSQL statements → BREAK |
Available in: PSQL
Added in: 1.0
Better alternative: LEAVE
Description: BREAK immediately terminates a WHILE or FOR loop and continues with the first statement after the loop.
Example:
create procedure selphrase(num int) returns (phrase varchar(40)) as begin for select Phr from Phrases into phrase do begin if (num < 1) then break; suspend; num = num - 1; end phrase = '*** Ready! ***'; suspend; end
This selectable SP returns at most
num
rows from the table Phrases. The variablenum
is decremented in each iteration; once it is smaller than 1, the loop is terminated with BREAK. The program then continues at the line “phrase = '*** Ready! ***';
”.
Since Firebird 1.5, use of the SQL-99 compliant synonym LEAVE is preferred.
Firebird Documentation Index → Firebird 1.5 Language Ref. Update → PSQL statements → BREAK |