码迷,mamicode.com
首页 > 数据库 > 详细

Oracle For 循环,字符串拼接,查找

时间:2018-02-10 18:15:26      阅读:247      评论:0      收藏:0      [点我收藏+]

标签:状态   ati   oracle   nbsp   oracl   color   epo   end   success   

--------------------------------------------------------------------------------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;
-------------------------------------------------------------------------------------

 

Oracle For 循环,字符串拼接,查找

标签:状态   ati   oracle   nbsp   oracl   color   epo   end   success   

原文地址:https://www.cnblogs.com/xyzabc0004/p/8439283.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!