Subject Re: [firebird-support] If and For Select
Author Woody
paultugwell wrote:
> Basically i want to do this in a stored procedure
>
> if (X=0) then
> for select a from b into :c
> else
> for select a from b where z = :x into c
There are several ways you can do this but you can't split up the for
select statement like that.

One way is to iterate all records regardless and test them inside the loop:

for select a, z from b into :c, :y do
begin
if (x = 0) or (x = y) then begin
other stuff...

suspend;
end
end

or, you could combine the two tests inside the where clause of the SQL:

for select a from b where (:x = 0) or (z = :x) into :c do
begin
other stuff...

suspend;
end;

HTH
Woody (TMW)