aspose file tools*
The moose likes JDBC and the fly likes MySQL Triggers Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "MySQL Triggers " Watch "MySQL Triggers " New topic
Author

MySQL Triggers

Kavita Tipnis
Ranch Hand

Joined: Sep 21, 2008
Posts: 177
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,

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: MySQL Triggers
 
Similar Threads
Need a Better way for postgreSOL Triggers
design question: 2 application A & B; needs to be in sync when new data is created on B. howto?
regarding drop down
does any one know how i can delete a trigger if it exist in mysql ?
Commit problem