I am working with a nested set tree and reading through Joe Celko's trees
and hierarchies in sql source book to refresh the old brain.  In section
4.7.1 of the book he has an example that uses a do while statement.  It
looks like this concept can be implemented in SQLite by using the WITH
clause, but I don't fully understand it.  Might someone be able to help me
translate this into SQLite code?  Here is the beginnings of it:

while exists (select * from frammis where wgt = 0)
do update frammis
  set wgt =  ...
end while;

The ... is the following case statement, unless I am mistaken this is
pretty straight forward to convert, my big question is the code above.

case
when 0 < all ( select c.wgt
               from frammis as c
               left outer join frammis as b on b.lft = (select max(S.lft)
from frammis as s where c.lft > s.lft and c.lft < s.rgt)
               where b.part = frammis.part )
then ( select coalesce (sum(c.wgt*c.qty), b.wgt)
        from frammis as c
        left outer join frammis as b on b.lft = (select max(S.lft) from
frammis as s where c.lft > s.lft and c.lft < s.rgt)
      where b.part =  frammis.part )
else frammis.wgt
end


Pax vobiscum,
Sam Carleton
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to