问题解决 declare cursor c_cur is select * from t_dept_cate_cost_mapping; v_row t_dept_cate_cost_mapping%rowtype; v_num number(5) := 0; begin select count(*) into v_num from t_dept_cate_cost_mapping; open c_cur; for i in 1 .. v_num loop fetch c_cur into v_row; insert into t_dept_cate_cost_mapping_5 values (i, v_row.draft_department_id, v_row.exp_cate_id, v_row.cost_center_id); end loop; close c_cur; commit; end;
用sequence,sequence初始值、最大值还有每次变化都自己定义 update t_table a set a.id = s_your_sequence.nextval;根据rownum的值设定ID值,你可以update t_table a set a.id = rownum+1,也可以具体根据你的具体需求写个function
declare
cursor c_cur is
select * from t_dept_cate_cost_mapping;
v_row t_dept_cate_cost_mapping%rowtype;
v_num number(5) := 0;
begin
select count(*) into v_num from t_dept_cate_cost_mapping;
open c_cur; for i in 1 .. v_num loop
fetch c_cur into v_row;
insert into t_dept_cate_cost_mapping_5
values
(i,
v_row.draft_department_id,
v_row.exp_cate_id,
v_row.cost_center_id);
end loop;
close c_cur;
commit;
end;
update t_table a set a.id = s_your_sequence.nextval;根据rownum的值设定ID值,你可以update t_table a set a.id = rownum+1,也可以具体根据你的具体需求写个function