I need help putting together a query that will return all the sub-FOLDER names within a higher level folder. I don't want all the items within those subfolders to be listed, just the folder names. Does anyone have anything for this query?
Thanks!
LiveReport needed to list all the sub-folder names within a folder Posted byhilary.stamper@albertainnovates.ca (Stamper, Hilary)On 11/15/2017 11:28 AM I need help putting together a query that will return all the sub-FOLDER names within a higher level folder. I don't want all the items within those subfolders to be listed, just the folder names. Does anyone have anything for this query?Thanks![To post a comment, use the normal reply function]Forum:Content Server LiveReports ForumContent Server:Knowledge Center CS 16.2.2
Hi Hillary
If using SQL and you need a breadcrumb trail (as per previous post) then here is a CTE that works for me.
Just replace the Start Folder number with the top level folder dataid you are querying.
--Define CTEWITH Folders AS(--Anchor member definitionSELECT p.[ParentID] ,p.[DataID] ,p.[Name] ,p.[SubType] ,0 AS [Level] , CAST(p.[Name] AS VARCHAR(255)) AS Path
FROM [DTreeCore] pWHERE p.[DataID] = 12345 --Starting FolderAND p.[SubType] = 0UNION ALL
--Recursive member definitionSELECT c.[ParentID] ,c.[DataID] ,c.[Name] ,c.[SubType] ,[Level] + 1 , CAST(Path + ' / ' + CAST(c.[Name] AS VARCHAR(255)) AS VARCHAR(255))
FROM [DTreeCore] cINNER JOIN Folders d ON d.[DataID] = c.[ParentID]WHERE c.[SubType] = 0)
--Execute Query SELECT [ParentID],[DataID],[Name],[Level], [Path]FROM Folders
Regards
Nick
eLink : LiveReport needed to list all the sub-folder names within a folderLiveReport needed to list all the sub-folder names within a folder Posted bynicholas.goddard@derby.gov.uk (Goddard, Nicholas)On 11/15/2017 12:14 PM Hi HillaryIf using SQL and you need a breadcrumb trail (as per previous post) then here is a CTE that works for me.Just replace the Start Folder number with the top level folder dataid you are querying.--Define CTEWITH Folders AS(--Anchor member definitionSELECT p.[ParentID] ,p.[DataID] ,p.[Name] ,p.[SubType] ,0 AS [Level] , CAST(p.[Name] AS VARCHAR(255)) AS PathFROM [DTreeCore] pWHERE p.[DataID] = 12345 --Starting FolderAND p.[SubType] = 0UNION ALL--Recursive member definitionSELECT c.[ParentID] ,c.[DataID] ,c.[Name] ,c.[SubType] ,[Level] + 1 , CAST(Path + ' / ' + CAST(c.[Name] AS VARCHAR(255)) AS VARCHAR(255))FROM [DTreeCore] cINNER JOIN Folders d ON d.[DataID] = c.[ParentID]WHERE c.[SubType] = 0)--Execute Query SELECT [ParentID],[DataID],[Name],[Level], [Path]FROM Folders RegardsNick[To post a comment, use the normal reply function]Topic:LiveReport needed to list all the sub-folder names within a folderForum:Content Server LiveReports ForumContent Server:Knowledge Center CS 16.2.2
I'd also recommend perhaps using DTree, if this is something you want to run with any sort of frequency, to prevent future performance issues.
DTree being a view, and DTreeCore being the actual table upon which DTree is built.
The reason to useDTree instead of DTreeCore, in addition to future proofing, is that LiveReports “understands” DTree. As an example when using “DTree” you can check for certain permissions to be held by the end-user, using a %x that is set to “Filter Permissions”. As another example to have only Folders returned in a query you can include a %x that is set to “Filter Folders”, instead of using an explicit subtype number clause. Etc.
(Obligatory mention: it’s good practice for anyone writing a query against DTree to always include relevant permissions checks, in addition to understanding the security implications of their query. This is in case someone other than a sysadmin has access to running the LiveReport.)
-chris
From: eLink Entry: Content Server LiveReports Forum [mailto:livereportsdiscussion@elinkkc.opentext.com]Sent: Wednesday, November 15, 2017 10:21 AMTo: eLink RecipientSubject: [EXTERNAL] - Re LiveReport needed to list all the sub-folder names within a folder
[EXTERNAL] - Re LiveReport needed to list all the sub-folder names within a folder
Posted bynghazal@opentext.com (Ghazal, Nizar) On 11/15/2017 01:14 PM
Thank you all,
The query that I was after seemed to work with just:
Select * from DTree DT
Where DT.ParentID=457499 and subtype=0