oracle存储过程

初学oracle存储,游标循环取值,搞了一天,记录一下:

create or replace procedure P_WOW_TEST
/**********************************

***********************************/
is
  v_unitname   varchar2(100); --3,4
  v_tel        varchar2(200);  --1,2
  v_address    varchar2(80);  --5
  v_cust_type  varchar2(10);  --6
  v_tel_type   varchar2(10);  --7
  v_deal_type  varchar2(10);  --8
  v_act_date   varchar2(10);  --9
  v_county     varchar2(50);  --10
  v_password   varchar2(20);  --11
  v_staffno    varchar2(20);  --12
  v_actfrom97  varchar2(20);  --13
  v_citycode   varchar2(10);  --14
  temp_unitnum varchar2(20);
 

begin
  v_cust_type   := '1';  --6
  v_tel_type   := '1';  --7
  v_deal_type  := '1';  --8
  v_actfrom97  := 'A';  --13
  v_act_date   := to_char(sysdate, 'yyyymmdd');  --9
  v_password   := '';  --11
  v_staffno    :='wsw';  --12
 
  declare --游标
  cursor temp_unitnum_list is
  select unitnum from T_WOW_UNIT where flag_unit = '1' and unitnum in('37166954936', '37165525308', '37765912764');
 
  begin
    /*for unitnum in temp_unitnum_list*/
    open temp_unitnum_list;
      loop
      fetch temp_unitnum_list into temp_unitnum;
      exit when temp_unitnum_list%notfound;
     
 
select trim(t.unitname),
       substr(trim(t.unitnum), 4, 8),
       substr(trim(t.address), 0, 50),
       trim(a.origincode),
       trim(t.citycode)
  into v_unitname, v_tel, v_address, v_county, v_citycode
  from T_WOW_UNIT t, T_AREA a
 where t.areaname = a.areaname
   and t.flag_unit = '1'
   and t.unitnum = temp_unitnum;

     p_Dt_Insertdata(v_tel, --1:new tel
                     v_tel, --2:old tel
                     v_unitname, --3:new name
                     v_unitname, --4:old name
                     v_address, --5:address
                     v_cust_type, --6:0-个人,1-集团
                     v_tel_type, --7:1-单位电话
                     v_deal_type, --8:1-新增,2-修改
                     v_act_date, --9:to_char(, 'yyyy-mm-dd')
                     v_county, --10:区县
                     v_password, --11:password
                     v_staffno, --12:staffno-wsw
                     v_actfrom97, --13:A-新增,M-修改
                     v_citycode  --14:citycode
                     );
    
     end loop; close temp_unitnum_list;
     end;
end P_WOW_TEST;

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值