1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
|
CREATE OR REPLACE TRIGGER "TRG_MAJ_SOLD_CNG" AFTER UPDATE OF VALID ON USER_COFAT.DEM_CNG REFERENCING NEW AS NEW OLD AS OLD FOR EACH ROW
DECLARE
SOLD_ varchar2(10);
BEGIN
begin
select VAL1 into sold_
from init_grh
where COD_SOC = :new.cod_soc_jur
and LIB = 'SOLD_CNG';
exception when no_data_found then
sold_ := 'DEM';
end;
if :new.valid = 'O' then
if sold_='DEM' then
maj_sold_cng(:new.cod_soc,:new.mat_pers,:new.annee_cng,:new.code_m,:new.nbr_jours);
end if;
update cal_pers
set prec_cod_m = cod_m, cod_m = :new.code_m
where cod_soc = :new.cod_soc
and mat_pers = :new.mat_pers
and to_date(lpad(to_char(days), 2, '0') ||
lpad(to_char(months), 2, '0') ||
lpad(to_char(years), 4, '0'),
'dd/mm/yyyy') between :new.dat_debut and :new.dat_fin
and cod_m not in ('F', 'RH');
end if;
if :new.valid = 'A' then
if sold_ ='DEM' then
maj_sold_cng_annul(:new.cod_soc,:new.mat_pers,:new.annee_cng,:new.code_m,:new.nbr_jours);
end if;
update cal_pers
set cod_m = prec_cod_m
where cod_soc = :new.cod_soc
and mat_pers = :new.mat_pers
and to_date(lpad(to_char(days), 2, '0') ||
lpad(to_char(months), 2, '0') ||
lpad(to_char(years), 4, '0'),
'dd/mm/yyyy') between :new.dat_debut and :new.dat_fin
and cod_m not in ('F', 'RH');
end if;
end; |
Partager