procedure实例2

create or replace procedure pro_synchronize_bss IS
usercount number;
cursor cur is
    select * from v_xf_bss;
BEGIN
    for curitem in cur
    loop
        --dbms_output.put_line(curitem.code);
        if(curitem.realname is not null and trim(curitem.code) is not null)
        then
        if(exist_base_user(trim(curitem.code))=0)
        then
        
          if(curitem.CZLX='D')
          then
          insert into
                base_user(ID, code, realname)
                values(trim(curitem.code), trim(curitem.code), curitem.realname);
          commit;                                             
          else 
           --dbms_output.put_line('insert...');
           insert into
                base_user(ID, code, realname)
                values(trim(curitem.code), trim(curitem.code), curitem.realname);
          commit;
          end if;
        else
        
           if(curitem.CZLX!='D')
           then
           
           --dbms_output.put_line('update...');
           select count(*) into usercount from base_user tt1
                where tt1.code=trim(curitem.code) and tt1.realname=curitem.realname ;
           
           if(usercount=0)
           then
              update base_user tt2
                   set tt2.realname=curitem.realname  where tt2.code=trim(curitem.code);
              commit;
           end if;
           
           end if;
           
        end if;
        end if;
    end loop;
    commit;
end pro_synchronize_bss;

 

create or replace procedure pro_synchronize as
begin
    pro_synchronize_bzks;
    pro_synchronize_yjs;
    pro_synchronize_bss;
    pro_synchronize_xyzg;
    pro_synchronize_jzg_ltx;
    pro_synchronize_jzg;
    commit;
end pro_synchronize;

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值