Re: Nested Sets and custom sorting
From: Mark (mpluijmaekers_at_yahoo.com)
Date: 08/04/04
- Next message: Mingqing Cheng [MSFT]: "RE: Can I have an Update in an If statement if a field may not exist."
- Previous message: Roji. P. Thomas: "Re: Deleting duplicates"
- In reply to: Adam Machanic: "Re: Nested Sets and custom sorting"
- Next in thread: Adam Machanic: "Re: Nested Sets and custom sorting"
- Reply: Adam Machanic: "Re: Nested Sets and custom sorting"
- Reply: --CELKO--: "Re: Nested Sets and custom sorting"
- Messages sorted by: [ date ] [ thread ]
Date: 4 Aug 2004 00:01:48 -0700
"Adam Machanic" <amachanic@hotmail._removetoemail_.com> wrote in message news:<Ov4rdOWeEHA.3016@tk2msftngp13.phx.gbl>...
> Mark,
>
> Is the data re-ordered at runtime (e.g. can the user specify an order),
> or is the ordering static at build time (when you create the tree)? If the
> latter, just insert the nodes into the tree in whatever order you'd like to
> retrieve them. If the former, it will probably be easier (and more
> efficient) to return the SortIndex to the client and sort the data there.
The ordering is static at the moment I (re-)build the menu. I tried to
insert the nodes into the tree in the correct order, but couldn't find
an elegant/fast solution to do this. The query that inserts a node
into the menu-table in Joe Celko's nested sets model looks like:
-- push when top has subordinates and set lft value
INSERT INTO #Stack
SELECT (@current_top + 1), MIN(T1.Nr), @counter, NULL, @level
FROM #Stack AS S1, @Tree AS T1
WHERE S1.child = T1.Parent
AND S1.stack_top = @current_top;
So in this case, the node with the lowest id (T1.Nr) is inserted first
into #Stack. In my case, the ordering of sub-nodes depends on the
value of the ListOrder and SortIndex fields of a node. And I can't
find a good way of inserting the nodes in the desired order without
using nested cursors or such. Anyone?
- Next message: Mingqing Cheng [MSFT]: "RE: Can I have an Update in an If statement if a field may not exist."
- Previous message: Roji. P. Thomas: "Re: Deleting duplicates"
- In reply to: Adam Machanic: "Re: Nested Sets and custom sorting"
- Next in thread: Adam Machanic: "Re: Nested Sets and custom sorting"
- Reply: Adam Machanic: "Re: Nested Sets and custom sorting"
- Reply: --CELKO--: "Re: Nested Sets and custom sorting"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|
|