0

How do I create a BEFORE UPDATE trigger that sends me a message when a specific field value in a table is modified? The PhP code is setting a field value to NULL but I can't find where the issue is in the code. I want to set up a trigger to find out who/when/where in the code it is happening or what is triggering the modification.

ie. Stakeholders table has a field called birthdate birthdate is changed to NULL on some process update (not sure what process is clearing it out). Not all birthdates are cleared, only 5 or 6 out of 100 records.

How can I find out what process is clearing out the field value? Can I use a trigger?

Jadestorm
  • 21
  • 1
  • First of all, you should use some profiler to analyse the queries almost in real time. – William Okano Jul 13 '16 at 21:52
  • 1
    Triggers don't generally "send messages" that I know of, but you could use a trigger to log something to another table (though it still won't be able to tell you what triggered it), or raise an error when the change occurs (assuming your code cares if the updates succeed). – Uueerdo Jul 13 '16 at 21:58
  • How do I set it up to raise an error? – Jadestorm Jul 13 '16 at 22:04
  • Unfortunately, I am not too experienced with that, it's more of a "something I've seen done". I think the answer [here](http://stackoverflow.com/a/7189396/4104224) may point you in the right direction though. – Uueerdo Jul 14 '16 at 16:49

0 Answers0