This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

MySQL Triggers

 
Kavita Tipnis
Ranch Hand
Posts: 177
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to save only the modified fields in a history/log table with the old and new values.
I was just experimenting with triggers to achieve this, however I want to do it dynamically on the columns
For example:
IF Old.colname != New.colname THEN //do something
where colname is a fetched from a cursor looping through all the column names. So far it seems like a MySQl limitaiton or I might be missing something
I have my custom DAO pattern and so I am avoiding to check for all the field changes in the code.Also I have data split across in multiple tables,
Looks like lot of people have dealt with this but not in MySQL as of now.

After this post I did create a stored procedure which emits out a trigger and I tried using a prepared statement to create the trigger on the fly but MySql does not support triggers in prepared statements, is there any fix available or any suggestions on how to handle this otherwise.


Thanks,

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic