0

我有两个名为table1and的表table2table1有字段code varcharstate int. table2有字段code varcharname varchar.

我有这个交易。

START TRANSACTION;
INSERT INTO TABLE1 (CODE,STATE)VALUES ('001',1);
INSERT INTO TABLE2 (CODE,STATE)VALUES ('001','X VALUE');
COMMIT;

table2有触发器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 |

问题:如何在触发器中获取state插入到同一事务中的行的字段值。

4

0 回答 0