Re: Extracting Parent Model from Nested Sets Model

From: Flavio Botelho <nuncanada_at_ig.com.br>
Date: 22 Jan 2003 10:00:17 -0800
Message-ID: <de0df942.0301221000.4efba471_at_posting.google.com>


nuncanada_at_ig.com.br (Flavio Botelho) wrote in message
> > I do not know MySQL, so I guessed at the translation to SQL Server:
> >
> > BEGIN
> > DECLARE _at_next_brother INTEGER;
> DECLARE _at_parent_left INTEGER;
> DECLARE _at_parent_right INTEGER;
> SET _at_parent_left = 7;
> SET _at_parent_right = 16;
>
> SET _at_next_brother = @parent_left+1;
>

I missed this, it should be:

SELECT _at_next_brother:=CASE WHEN lft >= @next_brother Instead of:
> > SELECT CASE WHEN lft >= _at_next_brother

Is this possible in other SQL dialects? To updated an user variable inside a SELECT?

> > THEN rgt+1
> > ELSE _at_next_brother END AS child,
> > part AS parent
> > FROM Frammis
>
> WHERE lft >= _at_parent_left AND rgt <= @parent_right
> HAVING child = rgt+1
>
>
> > ORDER BY lft;
> > END;
Regards,
Nuncanada Received on Wed Jan 22 2003 - 19:00:17 CET

Original text of this message