|Subject||Re: [firebird-support] Annoying: CTE "CTE2" is not used in query|
>>If I select from COMBINED, the sql runs but as below I get an error.This is pretty annoying when constructing a large SQL with many
>>CTEs and you want to test each one and combinations of them. I canget why the error is there, but any other suggestion?
>>generated from a large complex piece of code,
>>CTE1 as (select 1 as ID from rdb$database),
>>CTE2 as (select 2 as ID from rdb$database),
>>(select * from CTE1
>> select * from CTE2),
>>select * from CTE1
>This is even more annoying when the "large SQL with many CTEs" is
>and you've got to make sure that the large complex piece of codedoesn't generate a CTE that doesn't happen to be used this time.
Unlike Louis, I don't understand why this results in an error, I'd say
Firebird is too picky in this case.
You can circumvent such errors by simply adding CTEDummy as below, if
you include all CTEs in CTEDummy, you should not get the annoying error.
However, I don't know how this would affect performance - it worked
perfectly against rdb$database in the below example ;o).
CTE1 as (select 1 as ID from rdb$database),
CTE2 as (select 2 as ID from rdb$database),
(select * from CTE1
select * from CTE2),
join CTE2 on 1=2
join COMBINED on 1=2)
select CTE1.* from CTE1
left join CTEDummy on 1=2