I have a table t with one column i of type int, with a few rows. I want to loop over it. Of course, I can write a select query for this. But I am learning procedures and wrote a procedure,
set term ^;
create procedure qt returns(a int) as
begin
for select i from t into :a do
suspend;
end^
set term ;^
But when I call this procedure, I only get one row back,
execute procedure qt;
I see,
A
============
1
I think I do not understand suspend
.
Stored procedures with a
SUSPEND
in them are so called selectable procedures. You execute them usingSELECT
:or
The
EXECUTE PROCEDURE
statement is only for procedures that produce a single row result. If you use it for a selectable stored procedure, then it will only produce a single row (and exit when it hitsSUSPEND
).In response to your inquiry about what is documented about this:
SUSPEND
,EXIT
andEND
in selectable and executable procedures (slightly modified to fit):SELECT
and executed withEXECUTE PROCEDURE
.