oralce plsql 游标双循环实现 一个表中id的插入

declare
  tempId1   department.id%type;
  tempId2   department.id%type;
  cursor c1  is select id from department where rownum between 100 and 200;
  cursor c2  is select id from department;
  sharedataId     share_data.id%type;
  i  long :=0;
begin
    for c_temp1 in c1  loop
              for c_temp2 in c2  loop
                      select hibernate_sequence.nextval into sharedataId from dual;
                      insert into share_data values(sharedataId,0,c_temp2.id,c_temp1.id);
                      dbms_output.put_line('ccc');
                      commit;
              end loop;
    end loop;
end;

猜你喜欢

转载自supanccy2013.iteye.com/blog/1954058