Subject | AW: [firebird-support] begin-end with different conditions |
---|---|
Author | Olaf Kluge |
Post date | 2012-10-08T08:35:04Z |
Hello SET,
thank you!
Sorry, no need to complicate things with a CTE. The following at least works
with EXECUTE BLOCK:
execute block (iv1 char(1) = ?)
returns (b varchar(32), c varchar(32), d varchar(32))
as
begin
for
select b, c, d
from table_a
where :iv1 is null
union
select b, c, d
from table_b
where :iv1 is not null into :b, :c, :d
do
begin
suspend;
end
end
HTH,
Set
[Non-text portions of this message have been removed]
thank you!
>>Hello,Hence, I put it within
>>
>>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.
>brackets before WITH and SELECT. One of these you have to delete, the otherjust remove the brackets.
Sorry, no need to complicate things with a CTE. The following at least works
with EXECUTE BLOCK:
execute block (iv1 char(1) = ?)
returns (b varchar(32), c varchar(32), d varchar(32))
as
begin
for
select b, c, d
from table_a
where :iv1 is null
union
select b, c, d
from table_b
where :iv1 is not null into :b, :c, :d
do
begin
suspend;
end
end
HTH,
Set
[Non-text portions of this message have been removed]