gpt4 book ai didi

mysql:在触发器内使用过程

转载 作者:行者123 更新时间:2023-11-29 18:47:41 25 4
gpt4 key购买 nike

我需要调用一个在触发器内修改 root 密码的过程。这是流程

delimiter //
create procedure foobar ()
begin SET PASSWORD FOR 'root'@'localhost' = 'foobar';
end//
delimiter ;

这就是触发器

delimiter //
create trigger rootpass
after delete on map
for each row
begin
call foobar;
end //
delimiter ;

语法似乎是正确的,但是当我启动删除时,出现此错误

ERROR 1445 (HY000): Not allowed to set autocommit from a stored function or trigger

所以我想我正在尝试做一件被禁止的事情,有什么方法可以在mysql中工作吗?我知道整件事听起来很奇怪/可怕,但这是我的应用程序了解某些内容已被删除的方式。

最佳答案

执行语句时would cause an implicit commit of the current transaction ,触发器或存储函数中不允许使用该语句。

这包括由触发器或函数调用的存储过程中的语句 - 这里没有抽象层使无效操作变得更加有效。

关于mysql:在触发器内使用过程,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44516872/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com