惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

美团技术团队
T
The Blog of Author Tim Ferriss
月光博客
月光博客
阮一峰的网络日志
阮一峰的网络日志
Engineering at Meta
Engineering at Meta
量子位
I
InfoQ
Jina AI
Jina AI
Microsoft Security Blog
Microsoft Security Blog
H
Help Net Security
H
Hackread – Cybersecurity News, Data Breaches, AI and More
G
Google Developers Blog
J
Java Code Geeks
Recent Announcements
Recent Announcements
aimingoo的专栏
aimingoo的专栏
小众软件
小众软件
V
V2EX
腾讯CDC
P
Proofpoint News Feed
A
About on SuperTechFans
爱范儿
爱范儿
U
Unit 42
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Last Week in AI
Last Week in AI

博客园 - 蕭慶蘋

pymssql调用sqlserver存储过程带output 参数 数据库锁 oracle instr,substr 截取字符串 Oracle For 循环,字符串拼接,查找 Putty PSCP iis,webservice 启用 acrobat.exe 打印 iis,webservice 打印 Oracle查询包,同义词 sqlserver 游标 Oracle 截取字符串,取系统时间 Sqlserver连接Oracle数据库 Java 连oracle 12C 起步_PreparedStatement Java 连oracle 12C 起步 powershell excel 导入 sqlserver 更改存储过程的所有者 jquery-autocomplete 参数说明 了解SQL Server触发器及触发器中的事务 经典SQL语句大全 事务使用
循环读取写入表
蕭慶蘋 · 2018-02-10 · via 博客园 - 蕭慶蘋
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;