表a
本身id     id   
上级id     parentid
类别       type
操作id     oprid现在操作id这一列都是空,要更新一下。
如果某条记录中type=3,则将oprid更新为id(没有上级的,type一定为3)
如果记录中type不是3,则要通过树递归查询到上级的id(离子节点最近的一个父节点且type=3的),将这里查询到的id更新到oprid最后更新后得到下面这样的结果id    parentid   type   oprid
1      -          3       1
2      1          3       2
3      2          2       2
4      3          2       2
5      2          3       5
6      5          2       5
  

解决方案 »

  1.   


    update tba a
    set oprid=(case type when 3 then id
    else (select parentid from tba
    where connect_by_isleaf=1 and connect_by_root(id)=a.id
    start with type<>3
    connect by id=prior parentid and type<>3)
    end)
    /
      

  2.   


      1  update tba a
      2  set oprid=(case type when 3 then id
      3  else (select parentid from tba
      4  where connect_by_isleaf=1 and connect_by_root(id)=a.id
      5  start with type<>3
      6  connect by id=prior parentid and type<>3)
      7* end)
    SQL> select * from tba
      2  /        ID   PARENTID       TYPE      OPRID
    ---------- ---------- ---------- ----------
             1                     3          1
             2          1          3          2
             3          2          2          2
             4          3          2          2
             5          2          3          5
             6          5          2          56 rows selected.
      

  3.   


    我这会报ORA-00600:内部错误代码,参数:[qctcte1],[0],[],[],[],[],[],[]
    这是什么原因
      

  4.   

    先看看会话的 trc 文件,再处理
    http://dev.csdn.net/htmls/52/52618.html