Skip to content
Advertisement

MySQL Workbench “OLD” syntax changed?

I had a trigger set in MySQL workbench that used to accomplish what I wanted. Recently, my workplace updated MySQL workbench to version 6.3.10 across all computers and the triggers were dropped during the update for some reason.

Basically, the trigger should update a column with the current date when a different column is changed. This was previously achieved by using the following syntax:

if (NEW.colname <> OLD.colname or (OLD.colname is null && NEW.colname is not null)) 
then 
set NEW.othercolname = current_date()

The issue is when I try to recreate the same trigger in the new MySQL version and apply it, I am met with the error:

ERROR 1363: There is no OLD row in on INSERT trigger

It seems to me that MySQL is looking for a row named OLD, which does not exist; however, this syntax used to work in previous versions for the intended result. Can anyone suggest an alternative syntax to accomplish this?

Advertisement

Answer

ERROR 1363: There is no OLD row in on INSERT trigger

You’ve got MySQL Workbench set to create an INSERT trigger. As the error message says, there’s no OLD row in an INSERT trigger.

What you want is an UPDATE trigger.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement