Hi big-brains! I'm hoping that someone more savvy than I am can solve this problem. I'm stumped on making a particular LiveReport more efficient. The goal is to find all folders with a certain naming convention (say: "Special"), then list all items (folders and docs) underneath those folders where said items' permissions differ from the root node's.
I've tried two different approaches but neither scale. The two approaches I tried were:
SELECT DISTINCT %1, b.Name as Parent, d.Name AS Login, c.Permissions AS "gPermissions"
FROM DTree DTree, DTree b, DTreeACL c, KUAF d
WHERE DTree.ParentID=b.DataID
AND c.DataID=DTree.DataID
AND d.ID=c.RightID
AND (c.RightID, c.Permissions) NOT IN (SELECT RightID, Permissions FROM DTreeACL WHERE DataID=b.DataID)
START WITH b.Name LIKE '%%(Special)%%' CONNECT BY NOCYCLE PRIOR b.DataID=b.ParentID
ORDER BY b.Name
And also:
WITH ParList (ItemID, RootID) AS
( SELECT a.DataID AS ItemID, CONNECT_BY_ROOT b.DataID AS RootID from DTree a, DTree b
WHERE a.ParentID=b.DataID
START WITH b.Name LIKE '%%(Special)%%' CONNECT BY NOCYCLE PRIOR b.DataID=b.ParentID
)
SELECT %1, b.Name AS ParentName, c.Name AS RootName, a.Permissions AS "gPermissions", d.Name AS UserName FROM DTree DTree, DTree b, DTree c,
KUAF d,
((
SELECT DISTINCT b.ItemID, b.RootID, a.RightID, a.Permissions AS Permissions FROM DTreeACL a, ParList b WHERE a.DataID=b.ItemID
MINUS
SELECT DISTINCT b.ItemID, b.RootID, a.RightID, a.Permissions AS Permissions FROM DTreeACL a, ParList b WHERE a.DataID=b.RootID )
UNION
( SELECT DISTINCT b.ItemID, b.RootID, a.RightID, -1 FROM DTreeACL a, ParList b WHERE a.DataID=b.RootID
MINUS
SELECT DISTINCT b.ItemID, b.RootID, a.RightID, -1 FROM DTreeACL a, ParList b WHERE a.DataID=b.ItemID
)) a
WHERE DTree.DataID=a.ItemID
AND c.DataID=a.RootID
AND b.DataID=DTree.ParentID
AND d.ID=a.RightID
ORDER BY RootName, ParentName, Name
Thanks for any help. It's a tricky one.
Ben