Question

Is there a way we could create a trigger to automatically calculate how many times a certain record have been targeted with a UPDATEcommand?

Does anyone ever achieved this? It could be useful for auditing. I personally use a table to manually add records every time my applications create or edit a record. But I do that like:

 try
   Table1.Post;
 finally
   auditTable.Insert;
   {...}
   auditTable.post;
 end;

The usability for this would come handy if we created a trigger to annotate on another table the user who did the changes, the moment, the IP and other information. I found only one example in web and it's here: MySQL Trigger after update only if row has changed

By the rules, I would like to ask How could we trigger every table on a database except the audit page in order to register insertions and updates made on every other table?

Was it helpful?

Solution

You could use triggers as already suggested. You could also add an extra field to each table and update the count on each update. You could write the sql statement out to a text file....

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top