I have a simple table of only a few columns. One of the columns is DOL (Date of Launch) another is DOR (Date of Recovery). I would like to write a trigger that activates when both of these fields are update, or a new record is inserted that calculates the number of days between the two date fields.
Currently i run a simple query;
UPDATE longestRecovery set record = DATEDIFF(DOR, DOL)
To do the work. But it seems to me I should be able to update the 'record' value with a trigger.
I've tried a number of things; I usually name it Calculate Record, Action time is set to 'After' and Event to 'Insert. But I've tried a number of combinations with no luck.
When I click 'Add' I get:
Error creating trigger
The specified trigger was unable to be created.
MySQL said: You do not have the SUPER privilege and binary logging is enabled (you *might* want to use the less safe log_bin_trust_function_creators variable)
or I might get:
MySQL said: Unknown system variable 'record'
Can someone tell me how to do this please?