create or replace procedure Pro_rateCalculate as
v_sc_id dim_service_center
v_count
v_allcount
v_count
v_allcount
v_datediff number;
v_rate number;
cursor cur_sc_id is
select sc_id from dim_service_center;
begin
open cur_sc_id;
LOOP
FETCH cur_sc_id
INTO v_sc_id;
EXIT WHEN cur_sc_id%NOTFOUND;
select count(*)
into v_count
from dim_service_center
inner join fact_repair_sheet on dim_service_center
fact_repair_sheet
inner join fact_vefpart on fact_vefpart
fact_repair_sheet
where ((fact_vefpart
and fact_vefpart
or (fact_vefpart
and fact_vefpart
and fact_repair_sheet
and dim_service_center
v_allcount
select count(*)
into v_count
from fact_verify
inner join fact_repair_sheet on fact_verify
fact_repair_sheet
inner join dim_service_center on dim_service_center
fact_repair_sheet
where fact_verify
CALLSTATUS =
and fact_repair_sheet
and dim_service_center
v_allcount
select count(*)
into v_count
from dim_service_center
inner join fact_repair_sheet on dim_service_center
fact_repair_sheet
inner join fact_vefpart on fact_vefpart
fact_repair_sheet
where ((fact_vefpart
and fact_vefpart
or (fact_vefpart
and fact_vefpart
and fact_repair_sheet
and dim_service_center
v_allcount
select count(*)
into v_count
from fact_verify
inner join fact_repair_sheet on fact_verify
fact_repair_sheet
inner join dim_service_center on dim_service_center
fact_repair_sheet
where fact_verify
CALLSTATUS =
and fact_repair_sheet
and dim_service_center
v_allcount
select Add_months(sysdate
into v_datediff
from dim_service_center
where sc_id = v_sc_id;
if v_allcount
v_rate :=
elsif v_allcount
v_rate :=
elsif v_allcount
v_rate :=
end if;
if (v_allcount
v_rate :=
end if;
if (v_datediff <
v_rate :=
end if;
insert into VEF_FUHERATE
(vef_fuherate_id
scid
auto_rate
change_rate
status
modify_status
createdate
updatedate)
values
(sys_guid()
end loop;
close cur_sc_id;
end;
From:http://tw.wingwit.com/Article/program/Oracle/201311/17432.html