donus_deg artırmayı yapan sp nin output degisken ismi
lokal_deg ise insert islemini yapacagın sp de bir yerel degisken.
bu ikisini kendi tablona vs. uyarladıgında select ifadesi lokal degiskene sp yi cagırıp donus degerini atayacak.
sende herhangi bir degisken gibi insert ifadesinde bu degiskeni kullanacaksın
hatta artırma icin ayrı bir procedure olusturmaya dahi gerek uok
asagıdaki ornegi incele:
Kod: Tümünü seç
CREATE TRIGGER USERLOG_TEKLIF FOR TEKLIF
ACTIVE AFTER INSERT OR UPDATE OR DELETE POSITION 999
as
declare variable TBL_ID integer;
declare variable USER_ID integer;
begin
--Insert:1,Update:2,Delete:3
select t.id from tablolar t where t.adi like 'TEKLIF' into :TBL_ID;
select u.id from users u where (u.adi like user) into :USER_ID;
if (:USER_ID is null) then
exception ex_user;
if (inserting) then
insert into USER_LOG (ID,RECORD_ID,TABLE_ID,USER_ID,OP_ID,TARIH,SAAT)
values(gen_id(GEN_USER_LOG,1),new.ID,:TBL_ID,:USER_ID,1, current_date ,current_time);
if (updating) then
insert into USER_LOG (ID,RECORD_ID,TABLE_ID,USER_ID,OP_ID,TARIH,SAAT)
values(gen_id(GEN_USER_LOG,1),old.ID,:TBL_ID,:USER_ID,2, current_date ,current_time);
if (deleting) then
insert into USER_LOG (ID,RECORD_ID,TABLE_ID,USER_ID,OP_ID,TARIH,SAAT,REFERANS)
values(gen_id(GEN_USER_LOG,1),old.ID,:TBL_ID,:USER_ID,3, current_date ,current_time,old.ref_no);
end