Oracle For 循环,字符串拼接,查找
--------------------------------------------------------------------------------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; -------------------------------------------------------------------------------------