mysql 5.2.3 在触发器内调用的过程出现语法错误

标签 mysql sql mysql-error-1442

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 上使用此命令,当我尝试插入行时,出现错误 1442 有什么帮助吗??

谢谢

最佳答案

    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

Within a stored function or trigger, it is not permitted to modify a table that is already being used (for reading or writing) by the statement that invoked the function or trigger.

关于mysql 5.2.3 在触发器内调用的过程出现语法错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4814710/

相关文章:

SQL 将行对转换为 MS ACCESS 数据库中的列

php - 我可以有一个 SQL 查询,其中我从 ID = 另一个查询的表中选择所有内容吗?

mysql - 更新 mysql 触发器中的同一行

MySQL触发器: ERROR #1442

mysql - 如何在更新之前触发 MYSQL 删除条目

java - 使用 BLOB 或 TEXT/CLOB 在字段中保存 HTML 数据

mysql - 使用 jsp 和 jboss 进行 hibernate

SQL Server - 如果两个特定字段都为空,则从 View 中排除记录

MySQL 触发器 : is it possible to delete rows if table become too large?

php - $wpdb->prepare 不像 mysql_real_escape_string 那样工作