leave
SQL/PL
Leave (exit) the specified loop
Syntax
leave_stmt:
LEAVE label_name
Description
The LEAVE statement leaves/exits the loop specified by label_name.
Example
create procedure bio_match(in bio_string char)
begin
declare author_name char(30) default null;
declare author_bio char(216) default null;
fetch_author: for author_row as authors cursor for
select * from author
do
if locate(bio_string, author_row.short_bio, 1) != 0 then
set author_name = author_row.full_name;
set author_bio = author_row.short_bio;
leave fetch_author;
end if;
end for;
if author_name is null then
select "No author found with short_bio containing:", bio_string;
else
select author_name, author_bio;
end if;
end;