Subject RE: [firebird-support] begin-end with different conditions
Author Svein Erling Tysvær
>Hello,
>
>is the following scenario possible (without a statement)?
>
>If inputvariable A is null then
>For select b, c, d from table a
>Else
>For select b, c, d from table b (same fields like table a but different informations (data))
>
>Begin
>
>End
>
>The Block begin-and have the same code. I don't need a begin-end-block for both conditions
>(if. then for select . begin-end else for select . begin-end)

I think this is quite simple, Olaf, just use a CTE:

[for] with tmp(b, c, d)
as
(select b, c, d from table_a
where cast(:ivA as char(1)) is null
union
select b, c, d from table_b
where cast(:ivA as char(1)) is not null)

[for] select b, c, d from tmp do
begin
...
end

The one thing I do not know (and haven't tested), is where to put FOR. Hence, I put it within brackets before WITH and SELECT. One of these you have to delete, the other just remove the brackets.

HTH,
Set