How to sort b sequence? FW: Order of returned VArraySet rids when using FindLinked with a VArraySet arg.

Ed Kleban Ed at Kleban.com
Wed Dec 14 19:38:34 CST 2005


Ok, I'm guessing the question below is irrelevant because as my last email
on the subject of "V4RB Confusion" notes, despite documentation errors to
the contrary is probably is FindLinked method that both takes an (inSet as
VArraySet) as an argument and returns a VArraySet as a result.  So I'm a bit
lost on how to implement what I need.

I have two tables.

The first is TblItems  which has some miscellaneous fields.

The second is TblTree which keeps the MANY:MANY parent/child
releationships and and sequence order of children for the records in
TblItems.   

TblTree has 3 fields:

    fTreeParent as VObjectPtr  // Rid of parent in TblItems
    fTreeChild as VObjectPtr   // Rid of child in TblItems
    fTreeSeq as UShort         // Relative sequence number of child.

So I now want to implement a method that will return a list of the children
in sequence order for a given parent.

First I get all the children records for a given parent:

    treeRidSet = TblTree.fTreeParent.FindLinked( _
                       parentItemRid,TblTree, TblItems )

What I would like to then do is:

    // Sort records by sequence number:
    orderedTreeRidSet = TblTree.Sort( treeRidSet, TblTree.fTreeSeq )

    // Retrieve TblItem Rids in the current sorted order:
    orderedItemRidSet = _
        TblTree.vlChildToItemLink.FindLinkedAsArraySet( _
            orderedTreeRidSet, TblTree, TblItems )

However, there is no such call as FindLlinkedAsArraySet, and I'm not sure it
would preserve the inSet order if there was.

So how do I do this?  I guess I could try and retrieve the child links
first:

    unorderedChildBitSet = _
        TblTree.vlChildToItemLink.FindLinkedAsBitSet( _
            treeRidSet, TblTree, TblItems)

    // Perform painful, expensive conversion from BitSet to ArraySet
    unorderedChildArraySet = VArraySet( unorderedChildBitSet )

But then how do I sort these based on the order of TblTree records in
orderedTreeRidSet ?

This one just has me stumped.  The only solutions that come to mind are:

1) Do all this much more slowly in SQL.  Yuck.

2) Combine the TblTree fields into TblItems where I have a sufficent set of
API calls to make this work... But now that TblTree is managing MANY:MANY
parent/child relationships his just isn't feasible.

3) Convince to you write ASAP a FindLinkedAsArraySet method that preserves
the same order of records in the VArraySet result as the same order in the
passed inSet argument.

Do you have some other suggestions to offer?


Thanks!
--Ed



------ Forwarded Message
From: Ed Kleban <Ed at Kleban.com>
Date: Wed, 14 Dec 2005 18:07:56 -0600
To: "Valentina Developers <valentina at lists.macserve.net>"
<valentina at lists.macserve.net>
Conversation: Order of returned VArraySet rids when using FindLinked with a
VArraySet arg. 
Subject: Order of returned VArraySet rids when using FindLinked with a
VArraySet arg. 

Hi Ruslan,

If I call:

FindLinked( 
 inSet as VSet, 
 inTableA as VTable,
 inTableB as VTable,
 inRecursionDirection as EVRecursionDirection = kFromParentToChild )
 as VArraySet 


Then what is the order of the InTableB rids within the returned VArraySet?

I am hoping it is the same as the order of the matching inTableA rids within
inSet
So that I can first Sort the elements of inSet and then use that to control
the order
of the rid values I get back from within the returned VArraySet.

Thanks!
--Ed

------ End of Forwarded Message




More information about the Valentina mailing list