zoukankan      html  css  js  c++  java
  • 循环读取写入表

    declare
      ln_plantid     number;
      ln_itemid      number;
      ln_checkResult number;
      lv_uom         varchar(50);
      ln_isExist     number;
    
    begin
      for cur in (select * from xxx x) loop
      
        begin
          select p.plant_id
            into ln_plantid
            from hcm_plant p
           where p.plant_code = cur.plantcode;
          dbms_output.put_line(cur.plantcode || '------' || ln_plantid);
        exception
          when others then
            continue;
            dbms_output.put_line('取工厂ID出错!');
        end;
      
        begin
          select i.item_id, i.primary_uom
            into ln_itemid, lv_uom
            from hcm_item i
           where i.item_code = cur.itemcode
             and i.plant_id = ln_plantid;
          dbms_output.put_line(cur.itemcode || '------' || ln_itemid ||
                               '-------' || lv_uom);
        exception
          when others then
            continue;
            dbms_output.put_line('取物料ID出错!'||cur.itemcode);
        end;
      
        select count(1)
          into ln_isExist
          from HME_ITEM_ONHAND_QUANTITIES t
         where t.plant_id = ln_plantid
           and t.item_id = ln_itemid
           and t.warehouse_code = cur.warehouse
           and t.locator_code = cur.locator
           and t.lot_number = cur.lotnumber;
      
        if ln_isExist > 0 then
          dbms_output.put_line('物料在库存表里面已经存在!');
          continue;
        else
        
          /*insert into HME_ITEM_ONHAND_QUANTITIES
            (plant_id,
             Item_Id,
             Warehouse_Code,
             Locator_Code,
             Loct_Onhand,
             Lot_Number,
             Uom_Code,
             Server_Id)
          values
            (ln_plantid,
             ln_itemid,
             cur.warehouse,
             cur.locator,
             cur.qty,
             cur.lotnumber,
             lv_uom,
             2);*/
                 
          dbms_output.put_line('-------------------------------------------------');
          
        end if;
      end loop;
    
    end;
  • 相关阅读:
    PHP 数组函数分类整理
    mysql 数据库中 int(3) 和 int(11) 有区别么???
    理解PHP的运行机制
    类与对象
    PHP函数补完:call_user_func()
    linux 软件安装目录详解
    Linux下安装Redis
    Redis简介,应用场景,优势
    idea自动抽取变量快捷键设置
    全局捕获异常(适用于SpringMvc,SpringBoot项目)
  • 原文地址:https://www.cnblogs.com/xyzabc0004/p/8439307.html
Copyright © 2011-2022 走看看