以儲存過程實現比對不同表的金額,提公升測試效率

2021-06-23 02:41:02 字數 4015 閱讀 6921

工作中經常要比對承保系統和再保系統的金額,寫了以下的儲存過程以提高測試效率,比對涉及出單和批單的資料,涉及表 承保的是 t_policy_coverage ,

再保的表是:t_ri_policy_inte***ce和t_ri_riskunit_inte***ce

create or replace procedure test_wang(nu in varchar2) is

--通過&取輸入的值    

n1          number;

n2          number;

n3          number;

endorse_num number;

/*   pnum number := #*/

begin

-----------------------------------判斷出單時再保的保額、保費是否與承保一致----------

select count(*)

into n1

from ((

---------------比對t_policy_coverage 與  t_ri_policy_inte***ce的保額、保費

select sum(t.insured_amount) as 保額,

sum(t.total_actual_premium) as 複核保費

from auto_opr.t_policy_coverage t

where t.policy_no = nu

minus

select sum(t.sum_insured) as 保額, sum(t.premium) as 保費

from rein_opr.t_ri_riskunit_inte***ce t,

rein_opr.t_ri_policy_inte***ce   t2

where t.ri_policy_id = t2.ri_policy_id

and t2.policy_no = nu

and t2.times = '0') union

(---------------比對t_policy_coverage 與  t_ri_riskunit_inte***ce的保額、保費

select sum(t.insured_amount) as 保額,

sum(t.total_actual_premium) as 保費

from auto_opr.t_policy_coverage t

where t.policy_no = nu

minus

select sum(t.sum_insured) as 保額, sum(t.premium) as 保費

from rein_opr.t_ri_riskunit_inte***ce t,

rein_opr.t_ri_policy_inte***ce   t2

where t.ri_policy_id = t2.ri_policy_id

and t2.policy_no = nu

and t2.times = '0'));

if n1 = 0 then

dbms_output.put_line('出單的再保資料正確');

else

dbms_output.put_line('出單的再保資料不正確');

end if;

-----------------------------------判斷批單時t_ri_policy_inte***ce的保額,保費,是否與承保一致----------  

select count(*)

into endorse_num

from auto_opr.t_endorse_coverage

where policy_no = nu;

if endorse_num = 0 then

dbms_output.put_line('承保沒有批單資料');

else

select count(*)

into n2

from (select *

from (select sum(t.insured_amount) as 保額,

sum(t.total_actual_premium) as 保費

from auto_opr.t_endorse_coverage t

where policy_no = nu

group by endorse_id

order by endorse_id asc)

minus

select *

from (select sum(t.sum_insured) as 保額,

sum(t.premikum) as 保費

from rein_opr.t_ri_policy_inte***ce t

where t.policy_no = nu

and t.times not in ('0')

group by t.times

order by t.times asc));

if n2 = 0 then

dbms_output.put_line('批單t_ri_policy_inte***ce的保額、保費正確');

else

dbms_output.put_line('批單t_ri_policy_inte***ce的保額、保費不正確');

end if;

-----------------------------------判斷批單時再保t_ri_riskunit_inte***ce的保額、保額變化,保費,保費變化是否與承保一致---------- 

select count(*)

into n3

from (select *

from (select sum(t.insured_amount) as 保額,

sum(t.endorse_amount) as 保額變化,

sum(t.total_actual_premium) as 保費,

sum(t.check_endorse_premium) as 保費變化

from auto_opr.t_endorse_coverage t

where policy_no = nu

group by endorse_id

order by endorse_id asc)

minus

select *

from (select sum(t.sum_insured) as 保額,

sum(t.sum_insured_changed) as 保額變化,

sum(t.premium) as 保費,

sum(t.premium_changed) as 保費變化

from rein_opr.t_ri_riskunit_inte***ce t,

rein_opr.t_ri_policy_inte***ce   t2

where t.ri_policy_id = t2.ri_policy_id

and t2.policy_no = nu

and t2.times not in ('0')

group by t2.times

order by t2.times asc));

if n3 = 0 then

dbms_output.put_line('批單t_ri_riskunit_inte***ce的保額、保額變化,保費,保費變化正確');

else

dbms_output.put_line('批單t_ri_riskunit_inte***ce的保額、保額變化,保費,保費變化不正確');

end if;

end if;

if n3 = 0 and n2 = 0 and n1 = 0 or (endorse_num = 0 and n1 = 0) then

dbms_output.put_line('pass');

else

dbms_output.put_line('fail');

end if;

end test_wang;

/

以組號的形式建立儲存過程

前段時間在群裡發現儲存過程乙個比較好的命名方式,以組號的形式命名,於是迫不及待到網上去搜些例子,看了以後覺得這種方式命名很有特點,這裡做下備忘,今天忽然想用就忘記了,所以又到網上找了一遍,翻箱倒櫃啊.命名方式 create procedure procname 1 這裡使用了分號,後面跟的是數字,p...

雜湊表的儲存過程

雜湊表的儲存過程 public static void main string args 訪問原理 每存入乙個新的元素都要走以下三步 1.首先呼叫本類的 hashcode 方法算出雜湊 2.在容器中找是否與新元素雜湊值相同的老元素,如果沒有直接存入 如果有轉到第三步 3.新元素會與該索引位置下的老元...

實現分頁的儲存過程

我們在做程式開發的時候有時候會經常要用到gridview datalist等控制項,當然gridview它本身就帶有分頁的功能,可是datalist的分頁就沒有提供,我們就不得不用 or儲存過程來實現,然而當顯示的資料量非常大的時候也有必要用到儲存過程對其進行分頁顯示,下面是實現分頁的一種方法 以p...