--------------------------------------------------------------------------------xqp 20180209 begin --找出有關這個配送單的相關記錄,遍歷 --一個配送單號可能由多個看板組成, for curr in (select t.kanban_id, t.plant_id, t.item_id, t.station_id, t.kanban_group_qty, t.ref_kb_dis_kid, t.kanban_qty from fy_ps_report_data t where instr(concat(CONCAT(',', t.ref_kb_dis_kid), ','), concat(CONCAT(',', to_char(p_kid)), ',')) > 0) loop if curr.ref_kb_dis_kid = to_char(p_kid) then --當看板的配送單ID號跟P_kid相等時,直接改狀態 ln_message_id := fy_ps_pck.update_ps_report_data(p_kanban_id => curr.kanban_id, p_kanban_status => 'D'); IF ln_message_id <> hcm_public_pck.g_success THEN -- RETURN ln_message_id; dbms_output.put_line('-------error1--------'); END IF; else --當不相等時,看板生成多個配送單號,取這個物料生成的配送數量 begin select t.apply_dis_qty into ln_ps_qty from fy_ps_line t where t.kid = p_kid and t.item_id = curr.item_id and t.plant_id = curr.plant_id; exception when others then ln_ps_qty := 0; end; ln_message_id := fy_ps_pck.update_ps_report_data(p_kanban_id => curr.kanban_id, p_kanban_qty => curr.kanban_qty - ln_ps_qty); IF ln_message_id <> hcm_public_pck.g_success THEN -- RETURN ln_message_id; dbms_output.put_line('----error2--------'); END IF; end if; end loop; end; -------------------------------------------------------------------------------------