Recursiv/hierarchical query?

Bart Pietercil bart.pietercil at cognosis.be
Thu Jan 22 05:46:10 CST 2009


Hi Ruslan;
On 22 Jan 2009, at 12:27, Ruslan Zasukhin wrote:

> On 1/22/09 10:17 AM, "Bart Pietercil" <bart.pietercil at cognosis.be>  
> wrote:
>
> Hi Bart,
>
>> For me an sql_function would be
>>
>> select collect_branch(tbl_a,
>> link_to_follow 
>> ,startfrom_recid,optional_nr_of_levels_before_returning)
>> which would return the recid's of the collected record, so I could
>> write this
>>
>> select tbl_a.* where recid in (select
>> collect_branch(tbl_a,link_to_follow,aRecid))
>>
>> Maybe I am to focused on my short term needs and we should be able to
>> give instead of a link_to_follow a join condition ?
>
> Link itself is enough info

Of course. What I meant was that this function should maybe also work  
when no link has been set up, and instead someone not using links  
would like to use a join condition ?


>
>
>
>> Maybe add also a count_branch_depth(tbl_A,link_to_follow,aRecID)  
>> which
>> would return the number of iterations before reaching the lowest  
>> level
>> of the branch.
>>
>> Then we could write something like:
>>
>> if(count_branch_depth(tbl_A,link_to_follow,aRecID) > someNumber) then
>> select tbl_a.* where recid in (select
>> collect_branch(tbl_a,link_to_follow,aRecid,someNumber))
>> else
>> select tbl_a.* where recid in (select
>> collect_branch(tbl_a,link_to_follow,aRecid))
>> end if
>
> I do not see sense because exists  
> optional_nr_of_levels_before_returning

But what will happen when you pass an optional_nr_of_levels that is  
higher then what exists.
I can think of places (ie when building a graphical representation of  
the tree) when I would like to know how deep the nesting will go so I  
can place a limit


Bart
PS: Is this something I can look forward too (if yes, I postpone my  
modification in the db for a few days) or is this more longterm (then  
I need to work around the issue)


>
>
>
>
>
> -- 
> Best regards,
>
> Ruslan Zasukhin
> VP Engineering and New Technology
> Paradigma Software, Inc
>
> Valentina - Joining Worlds of Information
> http://www.paradigmasoft.com
>
> [I feel the need: the need for speed]
>
>
> _______________________________________________
> Valentina mailing list
> Valentina at lists.macserve.net
> http://lists.macserve.net/mailman/listinfo/valentina



More information about the Valentina mailing list