Search code examples
mysqltriggersmysql-error-1193

Error Creating Trigger Unknown System Variable


I am trying to create a trigger in mysql using the following:

CREATE TRIGGER ins_daft BEFORE INSERT ON jos_ezrealty
FOR EACH ROW BEGIN 
SET preschool = livingarea*10.76391041671
END;

When I do I get the following error:

Error
SQL query:

CREATE TRIGGER ins_daft BEFORE INSERT ON jos_ezrealty
FOR EACH
ROW BEGIN 
SET preschool = livingarea * 10.76391041671 END

MySQL said: Documentation

#1193 - Unknown system variable 'preschool' 

I am trying to have the value of one field converted to square feet by multiplying by 10.76391041671. Can anyone see what I am doing wrong?

Thank you.


Solution

  • Any time you want to reference the columns of a row that fired the trigger, qualify them like NEW.column_name.

    Otherwise the SET command thinks you want to set a MySQL configuration variable called preschool.