I have been task to create a query on a table that actually has multiple level in it.
The way the table is organize is as follows. I have the following columns
SYSID, NODE_TYPE, PARENT, ISFIRST, NEXT, DOCNO
SYSIDis a unique Identifier for each row.NODE_TYPEis a value eitherForD.Fis for folder andDis for documentsPARENTis the parent folder where documents are supposed to be stored.ISFIRSTtell if this is the first value in the folder or not.NEXTis theSYSIDof the next value in the folder.
I must write a query that will find the folder, find all the entries in the folder, find if a sub folder exists and all sub values in the sub folders that could exists bellow that folder.
Something as shown in the screenshot.
The process can be many levels down.
Does anyone would have any idea on how I can create this?
I tried to create a cursor but I was not successful as it only went down one extra level.
I was thinking about creating a while loop but I do not have anything that I can think on using to perform the look without causing an infinite loop.
Any help would be appreciated.