Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

auditing with trigger. Whats the best way?

463410Nov 3 2005 — edited Nov 5 2005
Hello,

I would like to record any change in my data using triggers.

For Example, I have the following tables:

create table members
( member_id number,
name varchar2(100),
password varchar2(100),
address varchar2(100),
some other attributes ...
)

and

create table members_audit
( counter_seq number
stamp date,
action varchar2(1),
member_id number,
name varchar2(100),
password varchar2(100),
address varchar2(100),
some other attributes ...
)


Now, I would like to create a trigger that records and saves every change.
But only if there has really something changed.

Therefore, I got to compare every single OLD variable with the NEW variable. Is there a possibility to simply pass every single colum of the OLD variable and the NEW variable in a loop?

Do I have to create an extra trigger for each table or can I do something like this:

Create the following trigger for each table:

CREATE OR REPLACE TRIGGER my_trigger AFTER INSERT OR DELETE OR UPDATE ON [every_table] FOR EACH ROW


The whole auditing-table name is put together using the table name plus "_audit":

So, for example if I have the table "members" the trigger auditing table should be "memebers_audit". My auditing table for the table "customers" is "customers_audit". I do not want to create a trigger for every table manually.
Can I create a trigger on the whole schema?

How can I solve this problem?

Thank you in advance,

Christian
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 3 2005
Added on Nov 3 2005
9 comments
1,036 views