orcle复制树状图存储过程

树状图复制功能 :写了一个存储过程create or replace procedure copy_TemplateDetail(sourceId number, --源idu_id number, --更新的idu_createUser varchar2) is new_one_id number; new_two_id number; one_level nu...
摘要由CSDN通过智能技术生成
树状图复制功能 :写了一个存储过程
create or replace procedure copy_TemplateDetail(
sourceId number, --源id
u_id number,   --更新的id
u_createUser varchar2) is 
   new_one_id number;
   new_two_id number;
   one_level number;
   sourceDetailId number;
   sourceTwoDetailId number;
   two_level number;
 begin
     select count(1) into one_level  from 表A where templateId = sourceId and parentId is null;
     DBMS_OUTPUT.put_line(one_level);
   while one_level>0 loop
     SELECT S_ASSESSMENTTEMPLATEDETAILS.Nextval into new_one_id from dual;
        insert into 表A (ID,TEMPLATEID,DETAILLEVEL,PARENTID) select new_one_id,u_id,m.DETAILLEVEL,  m.PARENTID from (select a.*,rownum rowss from 表A a where a.templateId=sourceId and a.parentId is null  ) m where m.rowss=one_level;
         select m.id into sourceDetailId  from (select a.id ,rownum as rowss from 表A a where a.templateId=sourceId and a.parentId is null order by a.displayseq) m where m.rowss= one_level;
     select count(1) into two_level from 表A  where parentId = sourceDetailId;
      one_level:= one_level - 1;
      DBMS_OUTPUT.put_line(sourceDetailId);
      while two_level>0 loop
        SELECT S_ASSESSMENTTEMPLATEDETAILS.Nextval into new_two_id from dual;
        insert into 表A (ID,TEMPLATEID,DETAILLEVEL,PARENTID) select new_two_id,u_id,m.DETAILLEVEL, m.MINSCORE,new_one_id  from (select a.*,rownum rowss from 表A a where a.templateId=sourceId and a.parentId =sourceDetailId order by a.displayseq ) m where m.rowss=two_level;
        select m.id into sourceTwoDetailId  from (select a.id ,rownum as rowss from 表A a where a.templateId=sourceId and a.parentId=sourceDetailId order by a.displayseq) m where m.rowss= two_level;
         insert into 表A (ID,TEMPLATEID,DETAILLEVEL,PARENTID) select S_ASSESSMENTTEMPLATEDETAILS.Nextval,u_id,m.DETAILLEVEL,new_two_id  from (select a.*,rownum rowss from ASSESSMENTTEMPLATEDETAILS a where a.templateId=sourceId and a.parentId =sourceTwoDetailId order by a.displayseq ) m ;
         two_level:=two_level-1;
      end LOOP;
     end LOOP;
end copy_TemplateDetail;

 

java复制树状图 

1.获取一定量的序列值

2.根据级别,id,parentid 获取一个有序的list数组

start with detaillevel = #detaillevel# and templateId=#templateId#
connect by prior id = parentId
order siblings by displaySeq

3.for循环往里面塞id和parentId了

 

 

表达的永远不是他所说的内容,而是渴望被理解的心情。

                                                                                                ——苏更生

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值