MySQL Forums
Forum List  »  Triggers

Re: fetch updated columns in 'before update' trigger
Posted by: Jon Beyer
Date: September 05, 2019 09:03PM

> "Access the updated columns in a 'before update' trigger" contradicts itself---the result of an update can't be accessed before the update has occurred. So I can't make sense of the question.


The following statement would be updating col_a and col_b:

UPDATE my_table SET col_a = '1', col_b = '2'

In the trigger, I want a list of columns that are being updated, i.e. col_a and col_b.



> Nor do I understand "...updating the trigger..."---Triggers aren't updateable.

I supposed 'delete and recreate updated trigger' would have been more precise. My trigger could exhaustively make sure that none of the columns that I effectively want to make read-only are updated, but I don't want to have to modify my trigger every time I add a column. I want to basically say "is the list of updated columns == to just the one column that should still be able to be updated"


> Nor do I understand "...add more columns"---are you building an Update statement, or what?

I may add more columns in the future. The trigger isn't listening for addition of columns. But I don't want to need to rewrite my trigger whenever I add a new column to the database.

Options: ReplyQuote


Subject
Views
Written By
Posted
Re: fetch updated columns in 'before update' trigger
135
September 05, 2019 09:03PM


Sorry, only registered users may post in this forum.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.