ITPub博客

首页 > 数据库 > Oracle > oracle connect by

oracle connect by

原创 Oracle 作者:xiayulai 时间:2008-04-16 21:57:45 0 删除 编辑
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博客 ” ,链接:https://blog.itpub.net/7312700/viewspace-1002636/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
  • 博文量
    28
  • 访问量
    30207