日期:2014-05-16  浏览次数:20554 次

循环表记录,改变某列再插入表
DECLARE nNumber    int;


BEGIN 
 
  nNumber :=1;
  LOOP
    EXIT WHEN nNumber = 5;
   
    INSERT INTO t_pick_detail (order_number,line_number,type,uom,work_q_id,work_type,status,item_number,planned_quantity,picked_quantity
    ,staged_quantity,pick_location,picking_flow,load_id,pick_area,wh_id,create_date)
    SELECT order_number,line_number,type,uom,work_q_id,work_type,status,item_number,planned_quantity,picked_quantity
    ,staged_quantity,pick_location,picking_flow,load_id,pick_area,'Whouse' || TO_CHAR(nNumber),SYSDATE
    FROM t_pick_detail;
    Commit;
    nNumber := nNumber + 1;
   
    END LOOP;
end;