Discussion Locked

Oracle auditing

0 helpful
7 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

Could anyone give me some insight on what is the best way to implement auditing in an Oracle database? The problem is that physical data deleted, inserted or updated has to be stored and has to be associated with the appllication user (not Oracle user), date and type of action committed.

What is better -- to use triggers or stored procedures? I would be very grateful if anyone suggests some approaches.

7 replies

by ambily

Suggestion:

Assuming you have an application user_info table, you can have cols like last_user,last_update,row_status_flag in your tables which you can update when you do a transaction on the table.

Hope this helps.

by terziev

Thanks for the answer, but this really does not work. I need a way to track all changes that a User has made (and save the data that was deleted, updated or inserted) over a period of time and to be able to produce a report with all changes that theUser has committed to an audited table/s. With the approach you are suggesting I will be able to see only who is the last to modify a row from the table.

The idea which I proposed to client was to use a stored procedure that takes the USER_ID from the session and puts it in a separate user table (where also is kept the User audit status) where it is associated with the Oracle SESS_ID. The trigger (sits in every audited table) which knows the SESS_ID is able to see the USER_ID that is associated with the SESS_ID and to record the USER_ID in the AUD_TABLENAME (this is a table that has the same cols as the opriginal table but with three additional cols - USER_ID, DATE and ACTION_TYPE.)

The only problem is that client does not want to hear about adding a stored procedure that receives the need parameteres from the app. That's the problem in short. If you can help me, I'd be glad to grant you the points and will even consider giving you more.

by ambily

If the client does not want to hear about stored procedures, I guess you should turn database auditing on.(I can help you with this) But the catch was(this was nearly year back when I tried auditing) : - oracle database auditing stored the statementid only i.e. whether it is select,insert or delete. Enhancement 765412 had been filed to capture statements also.

I guess you should try the Oracle Metalink site.

Hope that helps

by terziev

We are getting closer:)
True, Oracle has auditing that can do that. The problem is that I also need to know the USER_ID (not Oracle User) of the application User besides the date, type of action and data deleted, amended or inserted.
One more try,please
p.s. you can write to my e-mail. Once I receive your e-mail I will grant you the points. Thanks for the effort

by ambily

Well what I can think of if you have auditing on is have a table which stores the oracle usernames and the application user_ids
and join this table with the audit tables like dba_audit_trail (which has username col)

Hope it helps :-)

This discussion is closed to new replies.