Subject | Re: [firebird-support] question: stored proc and FOR SELECT...DO |
---|---|
Author | Helen Borrie |
Post date | 2004-06-24T12:16:56Z |
At 12:06 PM 24/06/2004 +0000, you wrote:
logic of a SP is to begin at the beginning and execute its way through to
the end. So, for example, If you want to avoid having the proc go into the
loop at all if there are no rows, do something like this:
if (exists (select 1 from.....where (xyz))) then
begin
for select blah, blah, etc.
...
into :whatever, .... do
begin
...
suspend;
end
end
/heLen
>Hi all."Normal" behaviour is for execution to go where your logic takes it. The
>
>I have written a stored proc using the for select...do statement.
>
>My problem: the body of the loop will be processed when
>the select statement has no result (no record fit's to
>the WHERE clause).
>
>Is this the normal behaviour?
>I would expect that the loop body is only processed if
>records are found in the SELECT.
>
>If this is the normal behaviour, what's the best
>workaround to avoid the loop body beeing processed
>when no record has been found?
logic of a SP is to begin at the beginning and execute its way through to
the end. So, for example, If you want to avoid having the proc go into the
loop at all if there are no rows, do something like this:
if (exists (select 1 from.....where (xyz))) then
begin
for select blah, blah, etc.
...
into :whatever, .... do
begin
...
suspend;
end
end
/heLen