1

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?

Community
  • 1
  • 1
NaN
  • 8,596
  • 20
  • 79
  • 153
  • 2
    Yes this would be possible. – PeeHaa Jun 15 '13 at 19:23
  • Seriously though. Without an actual problem to solve this really cannot be answered. If this question is just about creating a trigger I'm pretty sure there is a dupe out there somewhere. – PeeHaa Jun 15 '13 at 19:31
  • Well, maybe I am noob or maybe this site is Q&A and not just P&S – NaN Jun 15 '13 at 20:22
  • I don't know what porn & sodomy has to do with anything ;), but you are correct that this is an Q&A. However the above post is missing an actual question (the `Q` in Q&A). – PeeHaa Jun 15 '13 at 20:30

1 Answers1

2

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....