Firebird 2.0
PSQL Reference
Manual

SUSPEND STATEMENT

Pupose

Use SUSPEND to return a row of data from a procedure to its caller.

Syntax

<suspend_stmt> ::=
   SUSPEND ;


Semantics

Suspends execution of a PSQL routine until the next value is requested by the calling application, and returns output values, if any, to the calling application.

If the procedure is called from a select statement, processing will continue at the statement following SUSPEND when the next row of data is needed. Use the EXIT statement – or let the code path end at the final END of the body – to signal that there are no more rows to return.

If the procedure is called from a EXECUTE PROCEDURE statement, then SUSPEND has the same effect as EXIT. This usage is legal, but not recommended.

Examples

The below creates a procedure that returns the a series of integers and stops as soon as a value larger than 1000 has been reached.

CREATE PROCEDURE range RETURNING ( a INTEGER ) AS
DECLARE i INTEGER = 1;
DECLARE j INTEGER = 1;
BEGIN
   a = i + j;
   i = j; j = a;
   IF (a>1000) THEN EXIT;
   SUSPEND;
END;


See also

EXIT statement; PSQL Programs; See the SQL Reference Manual for a description of using procedures in SELECT statements.


previous page goto index next page

Legal information


User comments:


Contributed by Zoren on 24 December 2006 05:38 AM

is RETURNING really a valid word along with RETURNS?

Contributed by xHDErhLMiWSpZbUHwx on 1 June 2008 09:46 AM

doors.txt;10;15

Contributed by Magda on 3 September 2012 01:00 AM

With the bases ldoaed you struck us out with that answer!

Contributed by cheap backlinks on 18 July 2014 06:16 PM

eOvJ5D Wow, great article post.Really thank you! Great.

Contributed by crorkz linkz on 2 August 2014 03:46 AM

OdVQZL Muchos Gracias for your blog article. Really Great.

Contributed by crorkz on 17 December 2014 02:30 PM

SgdLFi Very good blog article.Really looking forward to read more. Cool.


Extend this topic - Post a comment

Your name:
Your comment:
This post is plain text
This post is html formatted