<p>The trigger tries to access OLD or NEW row data that is not available at its timing, causing execution to stop.</p>
<p>MySQL Error 1363 ER_TRG_NO_SUCH_ROW_IN_TRG happens when a trigger references OLD or NEW rows in a timing where they do not exist, such as OLD in BEFORE INSERT. Remove the invalid reference or adjust the trigger timing to resolve the issue.</p>
There is no %s row in %s trigger
Error 1363 occurs when a trigger body references OLD or NEW pseudorecords that are unavailable in the trigger timing. MySQL raises the error and aborts the statement.
For example, referencing OLD.column in a BEFORE INSERT trigger fails because the OLD row is undefined prior to insert. Likewise, NEW.column is unavailable in an AFTER DELETE trigger.
The error is common during trigger creation or table alteration. It also shows up at runtime if a trigger definition was edited incorrectly or copied from another timing without updating row references.
Developers usually encounter it while migrating databases, refactoring audit triggers, or implementing soft-delete logic.
Unresolved, the error prevents DML operations on the table, blocking application workflows. Fixing it restores data integrity and system availability.
Using OLD in BEFORE INSERT or NEW in AFTER DELETE triggers triggers the error because the required record version does not exist.
Attempting to reference OLD in BEFORE UPDATE on columns defined as generated or virtual can also cause the issue if the engine cannot supply the old value.
Identify the invalid OLD or NEW reference, then adjust the trigger timing or remove the reference. Re-create the trigger with correct logic and test.
Optionally, split logic across multiple triggers so each uses only valid pseudorecords.
Audit columns often need NEW values in BEFORE INSERT. Move audit logic requiring OLD values to BEFORE UPDATE to avoid the error.
Soft-delete implementations may require OLD data in AFTER DELETE. Ensure the trigger timing matches the required row version.
Review MySQL documentation on which pseudorecords are available in each trigger timing before writing triggers.
Write unit tests executing INSERT, UPDATE, and DELETE to catch invalid row references early. Version triggers in a shared SQL repository like Galaxy to track safe changes.
Error 1235 This version of MySQL does not yet support triggers on both tables in same time event - occurs when conflicting triggers exist. Remove duplicates.
Error 1442 Can't update table in stored function/trigger because it is already in use - avoid self-referencing writes inside triggers.
Referencing OLD in BEFORE INSERT or NEW in AFTER DELETE when the corresponding row does not exist.
Developers duplicate a trigger for another timing but forget to alter row references appropriately.
Columns renamed or dropped cause outdated OLD or NEW references inside triggers.
Older MySQL versions may not support certain virtual column references, leading to missing row data.
Occurs when a trigger tries to update the same table it fires on, causing recursion. Use intermediate tables or AFTER triggers.
Raised when multiple triggers are defined for the same table, timing, and event in MySQL versions prior to 5.7. Modify or merge triggers.
Appears when a trigger references a table that was dropped or renamed. Update the trigger definition.
No. The OLD pseudorecord is only available in UPDATE and DELETE triggers because there is no previous row during an INSERT.
NEW represents the post-change row image, which does not exist after a DELETE. Use OLD instead.
Enable the general log temporarily, reproduce the error, and examine the failing statement along with trigger definitions.
Yes. Galaxy highlights invalid OLD and NEW references during trigger editing and allows version control so teams can review changes before deployment.