游标实例 Oracle

游标实例:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
declare cursor cur_mrbd is
      select mrbd_line, mrbd_part, mrbd_pt_desc, mrbd_src_nbr, mrbd_qty, mrbd_price, mrbd_curr, mrbd_vat, pt_um
      from mrbd_det join pt_mstr on mrbd_part = pt_part
      where mrbd_nbr = var_mrb_nbr
      order by mrbd_line;
      begin
        open cur_mrbd;
        loop
           fetch cur_mrbd into var_mrbd_line, var_mrbd_part, var_mrbd_pt_desc, var_mrbd_src_nbr,
               var_mrbd_qty, var_mrbd_price, var_mrbd_curr, var_mrbd_vat, var_pt_um;
           exit when cur_mrbd%notfound;
 
            --插入sdh_hist记录
            insert into sdh_hist(sdh_site, sdh_so_nbr, sdh_sod_line, sdh_dn_dn, sdh_dnd_line,
                sdh_dn_date, sdh_ord_date, sdh_cust, sdh_part, sdh_qty_ord, sdh_qty_spare,
                sdh_qty_shp, sdh_qty_spare_shp, sdh_um, sdh_um_rate_m, sdh_um_rate_d,
                sdh_sod_price, sdh_curr, sdh_ex_rate, sdh_so_vat,
                sdh_dn_type, sdh_so_slspsn, sdh_cost, sdh_crt_by, sdh_crt_date, sdh_prog_code,
                sdh_char1, sdh_char2, sdh_char3, sdh_char4, sdh_char5, sdh_char6, sdh_qty1, sdh_qty2)
            values(var_mrb_site, var_mrbd_src_nbr, 0, var_mrb_nbr, var_mrbd_line,
                var_mrb_date, var_mrb_date, var_mrb_vend, var_mrbd_part, 0, 0,
                var_mrbd_qty * var_sign, 0, var_pt_um, 1, 1,
                var_mrbd_price, var_mrbd_curr, GetExRate(var_mrbd_curr, var_mrb_date), var_mrbd_vat,
                 'R', var_mrb_slspsn, 0, var_user, sysdate, var_mrb_prog_code,
                var_mrbd_pt_desc, '', '', '', '', '', 0, 0);
        end loop;
        close cur_mrbd;
      end;

  

posted @   *ち黑サカ  阅读(144)  评论(0编辑  收藏  举报
编辑推荐:
· 智能桌面机器人:用.NET IoT库控制舵机并多方法播放表情
· Linux glibc自带哈希表的用例及性能测试
· 深入理解 Mybatis 分库分表执行原理
· 如何打造一个高并发系统?
· .NET Core GC压缩(compact_phase)底层原理浅谈
阅读排行:
· 手把手教你在本地部署DeepSeek R1,搭建web-ui ,建议收藏!
· 新年开篇:在本地部署DeepSeek大模型实现联网增强的AI应用
· 程序员常用高效实用工具推荐,办公效率提升利器!
· Janus Pro:DeepSeek 开源革新,多模态 AI 的未来
· 【译】WinForms:分析一下(我用 Visual Basic 写的)
点击右上角即可分享
微信分享提示