Subject | Re: [firebird-support] If and For Select |
---|---|
Author | Woody |
Post date | 2008-02-12T15:20:59Z |
paultugwell wrote:
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)
> Basically i want to do this in a stored procedureThere are several ways you can do this but you can't split up the for
>
> if (X=0) then
> for select a from b into :c
> else
> for select a from b where z = :x into c
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)