I was looking at creating a TRIGGER that will set the value of a column to its DEFAULT if the INSERT value happens to be an empty string.
My TRIGGER looks like this:
CREATE TRIGGER column_a_to_default
BEFORE INSERT ON table
FOR EACH ROW
BEGIN
IF NEW.a = '' THEN
SET NEW.a = 'some value';
END IF;
END
I would like to know if I can replace 'some value' with a way to set it to the DEFAULT value of the column. i.e.
SET NEW.a = a.DEFAULT
Thanks