0
DELIMITER |

CREATE TRIGGER RV1       
after insert on Iscr 
for each row 
call ProcRV1(new.Usere,new.Sub);

create procedure ProcRV1(nUsere varchar(15),nSub varchar(15))

delete from Iscr

where Usere=nUsere && Sub=nSub && Usere=Sub

|

使用表 Iscr 上的这个,当我尝试插入行时,我得到 ERROR 1442 任何帮助??

谢谢

4

1 回答 1

1
    DELIMITER |

    create procedure ProcRV1(nUsere varchar(15),nSub varchar(15))
    BEGIN
        delete from Iscr where Usere=nUsere && Sub=nSub && Usere=Sub;
    END
    |

    CREATE TRIGGER RV1       
        after insert on Iscr 
        for each row 
        BEGIN
            call ProcRV1(new.Usere,new.Sub);
        END
    |

    DELIMITER ;

编辑:现在看到你的SP:

好的,所以您试图在插入时从当前表中删除行。MySQL 不允许这样做。但一定有诀窍。像在这里做的事情http://crazytoon.com/2008/03/03/mysql-error-1442-hy000-cant-update-table-t1-in-stored-functiontrigger-because-it-is-already-used- by-statement-which-invoked-this-stored-functiontrigger/

参考这个:http ://dev.mysql.com/doc/refman/5.0/en/stored-program-restrictions.html

在存储的函数或触发器中,不允许修改调用函数或触发器的语句已经使用(用于读取或写入)的表。

于 2011-01-27T09:45:43.087 回答