Thursday, 8 September 2011

What kind of change was made

In addition to simply copying the data, I imagine that you will want to keep track of when the data was changed, which user made the change and what kind of change was made (insert, update or delete). In fact, let's think about what you need to record for each of these kinds of changes:
Insert - there is no "before" state, so in this case, you will want to make note that the row was inserted, and store all the "after" data, that is, all the data for that row.
Update - you want to store the "before" state: the values of each of the columns
Delete - you want to store the "before" state of the data, before it all disappeared.
Oracle provides a set of functions - INSERTING, UPDATING, DELETING - that can be called inside your trigger to determine the kind of DML activity currently being executed.

No comments:

Post a Comment