小编ido*_*ido的帖子

MYSQL-无法更新存储函数/触发器中的表,因为它已被调用此存储函数/触发器的语句使用

我不断收到此错误:“无法更新存储函数/触发器中的表‘wp_posts’,因为它已被调用此存储函数/触发器的语句使用”

当 Woocommerce 向WP_posts表中插入一条记录时,我希望触发器确定正在插入的新记录是否具有post_title (column) = 'scheduled_subscription_end_of_prepaid_term' (field data). 如果是这样,我希望触发器IDnew.post_content(新插入行中的列/数据)中提取一个。

提取 ID 后,我想更新 ID。该 ID 与新插入行的 ID 不同。

有人可以告诉我我做错了什么吗?

delimiter //
create TRIGGER DB.Cancel
before INSERT ON DB.wp_posts FOR EACH ROW

BEGIN

DECLARE updateid bigint;
Declare variable longtext;
declare variable2 longtext;

IF NEW.post_title = 'scheduled_subscription_end_of_prepaid_term' then

set updateid := NEW.id;
set variable := RIGHT(new.post_content, LOCATE(":", new.post_content));
set variable2 :=  LEFT(variable, LOCATE("2052", variable)-2);

update db.wp_posts
set post_status="wc-cancelled"
where id=variable2 and post_status='wc-processing';

end if; …
Run Code Online (Sandbox Code Playgroud)

mysql triggers

2
推荐指数
1
解决办法
2万
查看次数

标签 统计

mysql ×1

triggers ×1