Subject Re: [firebird-support] Problem returning multiple rows from a CTE-recursive procedure
Author Mark Rotteveel
On 2018-05-04 18:56, blackfalconsoftware@... [firebird-support]
wrote:
> I am not sure if I understand your explanation here...
>
> 1...
> Why would I test the input parameter, "PI_KEY_IN" for each row? I am
> only doing this to ensure that the client never sends an input value
> of zero(0).

That may be what you want to do, but it is not what your code will
actually do. And you may want to consider doing that before producing
rows, btw.

> 2...
> In the other email you sent you stated that...
> "A FOR .. DO is a loop construct, which either execute a single
> statement for each iteration (each row) in the loop, or a block of
> statements delimited by BEGIN and END."
>
> However. if this follows as most constructs, the "DO" part is the end
> statement to the "FOR". Or is this better understood as "FOR"
> everything I do here, "DO" the following... ???

No, the DO is not the end of the FOR, it signals that what follows is
done for each row produced by the FOR.

In short:

FOR <something that produces rows> DO <statement or block>

See also:

- WHILE:
https://www.firebirdsql.org/file/documentation/reference_manuals/fblangref25-en/html/fblangref25-psql-coding.html#fblangref25-psql-while
- FOR SELECT:
https://www.firebirdsql.org/file/documentation/reference_manuals/fblangref25-en/html/fblangref25-psql-coding.html#fblangref25-psql-forselect
- FOR EXECUTE STATEMENT:
https://www.firebirdsql.org/file/documentation/reference_manuals/fblangref25-en/html/fblangref25-psql-coding.html#fblangref25-psql-forexec

Mark