Firebird Documentation IndexFirebird 2.5 Language Ref. UpdatePSQL statements → BREAK
Firebird Home Firebird Home Prev: BEGIN ... END blocks may be emptyFirebird Documentation IndexUp: PSQL statementsNext: CLOSE cursor

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 variable num 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! ***';.

Important

Since Firebird 1.5, use of the SQL-99 compliant alternative LEAVE is preferred.

Prev: BEGIN ... END blocks may be emptyFirebird Documentation IndexUp: PSQL statementsNext: CLOSE cursor
Firebird Documentation IndexFirebird 2.5 Language Ref. UpdatePSQL statements → BREAK