Привет
FB 2.1
Это Эксперт так парсит или нельзя так писать
Не работает
select A.*
>From stuff_list A
inner join
(
Select GS.IDKey
from stuff_groups GS
where (cast(?IDViewType as integer)=0) and GS.idkey=?IDKey
union all
WITH RECURSIVE R_TREE (IDKEY) AS
( SELECT A.IDKEY
FROM stuff_groups A
WHERE A.IDKey=:LIDKey and (cast(?IDViewType as integer)=1)
UNION ALL
SELECT B.IDKEY
FROM stuff_groups B
inner join R_TREE A on B.IDPARENT = A.IDKEY and
B.IDPARENT<>B.IDKey )
Select IDKey from R_Tree
union all
Select GS.IDKey
from stuff_groups GS
where (cast(?IDViewType as integer)=2) and
not exists(Select GS1.IDKey
from Stuff_Groups GS1
where GS1.IDParent=GS.IDKey and
GS1.IDKey<>GS1.IDParent)
) as B on b.IDKey=A.idgroups
Работает
select A.*
>From stuff_list A
inner join
(
(WITH RECURSIVE R_TREE (IDKEY) AS
( SELECT A.IDKEY
FROM stuff_groups A
WHERE A.IDKey=:LIDKey and (cast(?IDViewType as integer)=1)
UNION ALL
SELECT B.IDKEY
FROM stuff_groups B
inner join R_TREE A on B.IDPARENT = A.IDKEY and
B.IDPARENT<>B.IDKey )
Select IDKey from R_Tree)
union all
Select GS.IDKey
from stuff_groups GS
where (cast(?IDViewType as integer)=0) and GS.idkey=?IDKey
union all
Select GS.IDKey
from stuff_groups GS
where (cast(?IDViewType as integer)=2) and
not exists(Select GS1.IDKey
from Stuff_Groups GS1
where GS1.IDParent=GS.IDKey and
GS1.IDKey<>GS1.IDParent)
) as B on b.IDKey=A.idgroups
Еще так.
select A.*
>From stuff_list A
inner join
(
Select GS.IDKey
from stuff_groups GS
where (cast(?IDViewType as integer)=0) and GS.idkey=?IDKey
union all
Select GS2.IDKEY from
(WITH RECURSIVE R_TREE (IDKEY) AS
( SELECT A.IDKEY
FROM stuff_groups A
WHERE A.IDKey=:IDKey and (cast(?IDViewType as integer)=1)
UNION ALL
SELECT B.IDKEY
FROM stuff_groups B
inner join R_TREE A on B.IDPARENT = A.IDKEY and
B.IDPARENT<>B.IDKey )
Select IDKey from R_Tree) as GS2
union all
Select GS.IDKey
from stuff_groups GS
where (cast(?IDViewType as integer)=2) and
not exists(Select GS1.IDKey
from Stuff_Groups GS1
where GS1.IDParent=GS.IDKey and
GS1.IDKey<>GS1.IDParent)
) as B on b.IDKey=A.idgroups
--
Dmytro Lendel
www.bagel.com.ua