初学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;