Google Search

Wednesday, July 27, 2011

Workspace Manager

A common requirement in any project would be to have auditing columns in a table.
This is to know who updated/Inserted/Deleted the records and at what time.

Generally programmers, have to write custom update statements, to update name and time of the records before it is being modified.

Did you know oracle has a in-built package to handle this requirement.
Just one line of code is sufficient to fulfill the above requirements.

begin
dbms_wm.enableversioning('EMP_TT','VIEW_WO_OVERWRITE');
END;
Where EMP_TT is the table you want to have versions of old records.

Thats it.

Now anyone who updates or inserts new records, all the changes will be stored in a different view, named as EMP_TT_HIST. This has columns Username and created time, which helps us identifying the source of change.
Even if the complete table is deleted, old records will be in this view.

But one drawback of this is the performance of DMLs might slow down, one needs to test for performance before being implemented in PRODUCTION.

No comments:

Post a Comment