My Oracle Support Banner

Access original field value after modification by earlier trigger (Doc ID 1591517.1)

Last updated on MARCH 08, 2017

Applies to:

MySQL Server - Version 5.7 and later
Information in this document applies to any platform.

Goal

 Suppose a table has two triggers with the same event and time, and that the first one modifies the NEW value of some field:

CREATE TRIGGER t_bi_1 BEFORE INSERT ON t SET NEW.my_field = 1;

CREATE TRIGGER t_bi_2 BEFORE INSERT ON t SET @x := NEW.my_field;

INSERT INTO t (my_field) VALUES (2);

 

The second trigger gets the value of NEW.my_field that was set by the first trigger (that is, @x will hold 1 rather than 2). How can it get the original value supplied by the INSERT instead?

Solution

To view full details, sign in with your My Oracle Support account.

Don't have a My Oracle Support account? Click to get started!


In this Document
Goal
Solution

This document is being delivered to you via Oracle Support's Rapid Visibility (RaV) process and therefore has not been subject to an independent technical review.
My Oracle Support provides customers with access to over a million knowledge articles and a vibrant support community of peers and Oracle experts.