| Oracle FAQ | Your Portal to the Oracle Knowledge Grid | |
Home -> Community -> Usenet -> comp.databases.theory -> Re: Extracting Parent Model from Nested Sets Model
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 @next_brother INTEGER;
> DECLARE @parent_left INTEGER;
> DECLARE @parent_right INTEGER;
> SET @parent_left = 7;
> SET @parent_right = 16;
>
> SET @next_brother = @parent_left+1;
>
I missed this, it should be:
SELECT @next_brother:=CASE WHEN lft >= @next_brother
Instead of:
> > SELECT CASE WHEN lft >= @next_brother
Is this possible in other SQL dialects? To updated an user variable inside a SELECT?
> > THEN rgt+1
> > ELSE @next_brother END AS child,
> > part AS parent
> > FROM Frammis
>
> WHERE lft >= @parent_left AND rgt <= @parent_right
> HAVING child = rgt+1
>
>
> > ORDER BY lft;
> > END;
Regards,
Nuncanada
Received on Wed Jan 22 2003 - 12:00:17 CST
![]() |
![]() |