update 从表 set out_Id=(select out_Id from 主表)for循环也是一条一条的插入 运行方式不一样而已
declare v_id tbl_pos_stock_removal.id%type; v_outId tbl_pos_stock_removal.out_man%type; cursor c_cur is select t.id, t.out_man from tbl_pos_stock_removal t ; begin open c_cur; loop
fetch c_cur into v_id,v_outId; exit when c_cur%notfound;
update tbl_store_pos p set p.user_id = v_outId where p.id in(select d.pos_id from tbl_pos_stock_removal_detail d where d.master_id = v_id) ; end loop; close c_cur; commit; end; 哈哈 搞好了 用游标 大家看看啊
insert into 从表名(out_Id) select out_Id from 主表名;这样应该就行了
完全可以用sql搞定 简单的复杂化 update tbl_store_pos p set p.user_id=(select out_man from tbl_pos_stock_removal_detail d where p.id=d.pos_id) where exists(select 1 from tbl_pos_stock_removal_detail f where p.id=f.pos_id)
v_id tbl_pos_stock_removal.id%type;
v_outId tbl_pos_stock_removal.out_man%type;
cursor c_cur is select t.id, t.out_man from tbl_pos_stock_removal t ;
begin
open c_cur;
loop
fetch c_cur into v_id,v_outId;
exit when c_cur%notfound;
update tbl_store_pos p set p.user_id = v_outId
where p.id in(select d.pos_id from tbl_pos_stock_removal_detail d
where d.master_id = v_id) ; end loop;
close c_cur;
commit;
end;
哈哈 搞好了 用游标 大家看看啊
insert into 从表名(out_Id) select out_Id from 主表名;这样应该就行了
完全可以用sql搞定 简单的复杂化
update tbl_store_pos p set p.user_id=(select out_man from tbl_pos_stock_removal_detail d where p.id=d.pos_id)
where exists(select 1 from tbl_pos_stock_removal_detail f where p.id=f.pos_id)