Subject | RE: [firebird-support] Limit recursion in CTE |
---|---|
Author | Sasha Matijasic |
Post date | 2008-08-13T19:31:36Z |
> is there any way how to limit recursion when using CTE. Something likeHi,
> select * from MyCTE
> OPTION (MAXRECURSION 3)
>
> that's in MSSQL.
>
this is probably not what you are asking for and you might already be aware of it, but you could do something like this
with cte as(
select ..., 0 lvl
from ... a
union all
select ..., a.lvl + 1
from ...
join cte...
)
select * from cte
where lvl < :max_level
Of course it's slower and more difficult to write than having it as an option of cte, but at least it works...
Sasha