declare
我們擁有十年網(wǎng)頁設(shè)計(jì)和網(wǎng)站建設(shè)經(jīng)驗(yàn),從網(wǎng)站策劃到網(wǎng)站制作,我們的網(wǎng)頁設(shè)計(jì)師為您提供的解決方案。為企業(yè)提供成都網(wǎng)站設(shè)計(jì)、成都網(wǎng)站制作、微信開發(fā)、小程序開發(fā)、成都手機(jī)網(wǎng)站制作、H5技術(shù)、等業(yè)務(wù)。無論您有什么樣的網(wǎng)站設(shè)計(jì)或者設(shè)計(jì)方案要求,我們都將富于創(chuàng)造性的提供專業(yè)設(shè)計(jì)服務(wù)并滿足您的需求。
--開始時(shí)間
v_date_start date:= to_date('2015-05-28 00:00:00', 'yyyy-mm-dd hh34:mi:ss');
--結(jié)束時(shí)間
v_date_end date:= to_date('2015-11-01 00:00:00', 'yyyy-mm-dd hh34:mi:ss');
--臨時(shí)變量
v_date_plus date;
type type_policy_no is table of ply_base_info.policy_no%type;
v_policy_no type_policy_no;
type type_compensation_max_amount is table of ply_duty.compensation_max_amount%type;
v_compensation_max_amount type_compensation_max_amount;
type type_id_ply_duty is table of ply_duty.id_ply_duty%type;
v_id_ply_duty type_id_ply_duty;
type type_insurance_end_date is table of ply_base_info.insurance_end_date%type;
v_insurance_end_date type_insurance_end_date;
cursor plyNumberCur is
select
pbi.policy_no,
pd.compensation_max_amount,
pd.cover_spouse,
pdn.noclaim_rate,
pdn.noclaim_amount,
pd.id_ply_duty,
trunc(pbi.insurance_end_date)
from ply_base_info pbi,
marketproduct_info mi,
ply_risk_group prg,
ply_plan pp,
ply_duty pd,
ply_duty_noclaim pdn
where pbi.created_date >=v_date_start
and pbi.created_date < v_date_plus
and pbi.policy_no is not null
and pbi.product_code= mi.marketproduct_code
and pbi.product_version=mi.version
and mi.product_class in ('02','03')
and pbi.id_ply_base_info = prg.id_ply_base_info
and prg.id_ply_risk_group = pp.id_ply_risk_group
and pp.id_ply_plan = pd.id_ply_plan
and pd.id_ply_duty = pdn.id_ply_duty(+);
v_cnt number;--用來統(tǒng)計(jì)是否有數(shù)據(jù)
begin
loop
v_date_plus:=v_date_start+1;--時(shí)間變化,查詢游標(biāo)時(shí),每天查詢一次
open plyNumberCur;--打開游標(biāo)
loop
--每1000條記錄取一次,最后一次不夠1000的也將取出,放到變量中
fetch plyNumberCur bulk collect into
v_policy_no,v_compensation_max_amount,v_id_ply_duty,v_insurance_end_date limit 1000 ;
for i in 1..v_policy_no.count loop
if v_compensation_max_amount(i) > 0 then
select count (pda.id_ply_duty) into v_cnt from ply_duty_attribute pda where pda.id_ply_duty = v_id_ply_duty(i) and pda.duty_attr_code='6';
if v_cnt>0 then
update ply_duty_attribute pda set pda.duty_attr_amount_value=to_char(v_compensation_max_amount(i)), pda.UPDATED_BY='lxg' where pda.id_ply_duty = v_id_ply_duty(i) and pda.duty_attr_code='6' and pda.UPDATED_BY<>'lxg';
else
insert into ply_duty_attribute(ID_PLY_DUTY_ATTRIBUTE,ID_PLY_DUTY,DUTY_ATTR_CODE,DUTY_ATTR_AMOUNT_VALUE ,POLICY_NO, CREATED_DATE,CREATED_BY,UPDATED_DATE,UPDATED_BY,ARCHIVE_DATE)
values(sys_guid(),v_id_ply_duty(i),'6',to_char(v_compensation_max_amount(i)),v_policy_no(i),sysdate,'lxg',sysdate,'lxg',v_insurance_end_date(i));
end if;
end if;
end loop;--for end;
commit;
--當(dāng)游標(biāo)中沒有數(shù)據(jù)將退出
exit when plyNumberCur%notfound;
end loop; --for end;
close plyNumberCur;
v_date_start:= v_date_start+1;
if v_date_start>= v_date_end then
exit;
end if;
end loop; --loop
end;
/
分享文章:oracle游標(biāo)批量處理數(shù)據(jù)
網(wǎng)頁鏈接:http://aaarwkj.com/article42/gihhhc.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供定制開發(fā)、Google、小程序開發(fā)、品牌網(wǎng)站設(shè)計(jì)、面包屑導(dǎo)航、響應(yīng)式網(wǎng)站
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)