Dragan,
Thanks!! This is exactly what I am looking for! It will take me a while to digest this thread! I had done a search on 'parent-child-grandchild, 'tree', etc. but what I found was not quite relevant, somehow I missed this thread.
I think that for now, to get the application done and out the door, which needs to be done very soon (2 weeks ago), parent-child will do. But in the near future I will need to support multiple levels of nesting.
I'll try to answer your questions after I read the thread and study it for a while.
>>Dragan,
>>
>>Yes. That's what I am doing, assembling the pieces of the query on demand by looping through the query conditions detail table.
>>
>>I have made some good progress, but not come up with a 'complete solution' for processing parent and child records. The code I wrote so far handles parent and child, but not an 'infinite number of descendants and descendant levels', which is what I think I want. I don't have any sample code for this, but I think that what I want is the type of code that would handle an exploded Bill of Materials with nesting of assembly parts and sub assemblies.
>>
>>If you have any suggestions on algorithms, data structure that would be great.
>
>I'd recommend thread #
600157, this type of recursion was discussed at length then.
>
>Looking at your code, are you saying that child conditions may be split into deeper conditions, or was the recursion thing related to just BOMs?
>
>If it's just the BOMs, then (in meta-code)
>
>
create cursor crsFinal
>*-- get the items which go in directly
>insert into crsFinal ;
>select <fieldlist here> where itemno not in (select parentitemno from assembly)
>
>*-- now get the ones which are assemblies
>select <fieldlist here> where itemno in (select parentitemno from assembly);
> into cursor tmp
>insert into crsfinal;
> select * from tmp where itemno not in (select parentitemno from assembly)
>*-- now somehow repeat the last two steps as long as there were any records to insert.
>
>This is the case where you have an assembly table as discussed in the thread I mentioned. If your assembly is self-referencing, then it'd look a bit different. The last time I had to deal with multi-level assembly lists was more than seven years ago, so forgive me if I'm a bit rusty here.