Subject Re: [firebird-support] Stored procedures
Author Martijn Tonies
Hello Andre,

> I've made my first steps with stored procedures. The documentation
> provides some simple examples like:
>
> ALTER PROCEDURE "F_GET_ID"
> RETURNS
> (

Even easier:
ID INTEGER
> "id" INTEGER
> )
> AS
> BEGIN
> "id" = 1234567890;

id = 12931231;

(without quotes)

> END
>
> There is no syntax error, but I get no result set. So I read a little
> bit more the manual and find "suspend", and now:
>
> ALTER PROCEDURE "F_GET_ID"
> RETURNS
> (
> "id" INTEGER
> )
> AS
> BEGIN
> "id" = 1234567890;
> suspend; <<--------
> END
>
> it works.
>
> My Question: are all examples that I found wrong, or did I some mistakes?

No. A "suspend" make a stored procedure select-able. The engine will
suspend further procedure execution and will continue if the client or
process fetching results from the procedue will ask for a new row. If
it doesn't do that, the procedure will not finish (when in a loop).

For procedures that don't have "suspend" in them, you can call them via
EXECUTE PROCEDURE <procedure> ( in parameters ) returning_values
:out1, :out2 etc...

With regards,

Martijn Tonies
Database Workbench - developer tool for InterBase, Firebird, MySQL & MS SQL
Server
Upscene Productions
http://www.upscene.com