I have two tables called table1 and table2.
table1 has fields code varchar, state int.
table2 has fields code varchar, name varchar.
I have this transaction.
START TRANSACTION;
INSERT INTO TABLE1 (CODE,STATE)VALUES ('001',1);
INSERT INTO TABLE2 (CODE,STATE)VALUES ('001','X VALUE');
COMMIT;
table2 has the trigger trigger1
CREATE TRIGGER TRIGGER1 AFTER INSERT ON TABLE2
FOR EACH ROW BEGIN
DECLARE STATE INT;
SET STATE=(SELECT STATE FROM TABLE1 WHERE CODE=NEW.CODE); -- MY QUESTION.
IF (STATE=0 )THEN
DO SMETHING....
END IF;
END |
Question: How I can get in the trigger the value of the field state of the the row inserted in the same transaction.