I am trying to write a before delete trigger on mysql table here’s is what I am trying to do exactly; I need a specific record to always be in the table so say for example the record is deleted or updated the trigger would simply reinsert the initial record.
EXAMPLE
Tablename: Users
Table Columns(3):ID,Username,Password
and I am trying to keep the following record from being deleted(Initial Record)
Username=Dames, Password=Password
However Im new to triggers and have been trying a thing or 3 but it really seems I need some help, I hope I made the question clear, and thanks alot.
If you’re happy to hard-code into the triggers the details of the record that you wish to preserve, then you could do something like:
Otherwise, I’d recommend adding an additional boolean column to the
Userstable—e.g.locked:Then setting the value of that column to be
TRUEon the record(s) that you wish to preserve:Then creating triggers along the following lines: