BREAK

<< BEGIN ... BLOCKS may be empty | FB 2.5 Language Reference | CLOSE cursor >>
<< BEGIN ... BLOCKS may be empty | FB 2.1 Language Reference | CLOSE cursor >>
<< BEGIN ... BLOCKS may be empty | FB 2.0 Language Reference | 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.

See also:
Stored procedure and trigger language

back to top of page
<< BEGIN ... BLOCKS may be empty | FB 2.5 Language Reference | CLOSE cursor >>
<< BEGIN ... BLOCKS may be empty | FB 2.1 Language Reference | CLOSE cursor >>
<< BEGIN ... BLOCKS may be empty | FB 2.0 Language Reference | CLOSE cursor >>