This is main question please help me for this

这是我的代码:

BEGIN

DECLARE TMPCOL VARCHAR(100);

SET TMPCOL= 'ID';

SET @s = CONCAT('INSERT INTO TMP(DATA1, DATA2) VALUES ("DATA",OLD.',TMPCOL,');');

PREPARE stmt1 FROM @s;

EXECUTE stmt1;

DEALLOCATE PREPARE stmt1;

END

最佳答案

您不需要动态SQL。这实际上是相同的:

BEGIN
    INSERT INTO TMP (DATA1, DATA2)
        VALUES ('DATA', OLD.ID);
END;


这应该可以触发。否则,未定义old

09-10 21:20