Home » SQL & PL/SQL » SQL & PL/SQL » triggers
triggers [message #38411] Wed, 17 April 2002 02:14 Go to next message
krishna
Messages: 141
Registered: October 1998
Senior Member
Hi!

I need your help, i want to create a trigger on a table before update, such that it should know which field(s) are updated. Once i got the field(s), i can feed other table having fields:
table_name,field_name,timestap.
I don't want to create a trigger on each field .

Best Regards
Krishna
Re: triggers [message #38414 is a reply to message #38411] Wed, 17 April 2002 04:00 Go to previous messageGo to next message
Epe
Messages: 99
Registered: March 2002
Member
Hello,

if I understand your problem correctly, you want to keep track of the updates of one particular table by populating the table with structure (table_name, field_name, timestamp), using a before update trigger.
==>
Suppose the table you want to update table_A(field1,field2), and put the tracking data in table_log with the structure mentioned above.
==>
create or replace trigger
before update on table_A
for each row
begin
if :new.field1 <> :old.field1
then
insert into table_log(table_name,field_name,timestamp)
values('table_A','field1',sysdate);
end if;
if :new.field2 <> :old.field2
then
insert into table_log(table_name,field_name,timestamp)
values('table_A','field2',sysdate);
end if;
end;

I hope this helps you, succes,

epe
Re: triggers [message #38440 is a reply to message #38414] Wed, 17 April 2002 17:19 Go to previous message
krishna
Messages: 141
Registered: October 1998
Senior Member
Greetings! Epe

Thanks a lot for your reply with solution.

Best Regards
Krishna
Previous Topic: seng
Next Topic: Trigger Problem
Goto Forum:
  


Current Time: Thu Apr 25 11:21:38 CDT 2024