Oracle connect by

xiayulai發表於2008-04-16
declare
maxl number;
idnew number;
begin
for t in (select id from t2) loop
select max(level) ll into maxl from t1 start with id=t.id connect by prior pid=id;
select id into idnew from
(select level ll, id,pid from t1 start with id=t.id connect by prior pid=id)
where ll=maxl-1;
update t2 set id=idnew where id=t.id;
end loop;
commit;
end;[@more@]

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/7312700/viewspace-1002636/,如需轉載,請註明出處,否則將追究法律責任。

相關文章