Mysql创建触发器时提示new表不存在,怎么解决?
USE`test`;DELIMITER$$DROPTRIGGERIFEXISTStest.desktop_test_AFTER_INSERT$$USE`test`$$CR...
USE `test`;
DELIMITER $$
DROP TRIGGER IF EXISTS test.desktop_test_AFTER_INSERT$$
USE `test`$$
CREATE DEFINER = CURRENT_USER TRIGGER `test`.`desktop_test_AFTER_INSERT` AFTER INSERT ON `desktop_test` FOR EACH ROW
set @tv=1000 $$
set @newdate=new.cdate $$
set @newh=new.h $$
insert into check_log_test select cdate,h,(case when pv_pc<=@tv then 1 else 0 end),pv_pc from desktop_test where cdate=@newdate and h=@newh $$
DELIMITER ;
上面是写的触发器
一直提示1109,unknown table 'new' in field list sql statement 展开
DELIMITER $$
DROP TRIGGER IF EXISTS test.desktop_test_AFTER_INSERT$$
USE `test`$$
CREATE DEFINER = CURRENT_USER TRIGGER `test`.`desktop_test_AFTER_INSERT` AFTER INSERT ON `desktop_test` FOR EACH ROW
set @tv=1000 $$
set @newdate=new.cdate $$
set @newh=new.h $$
insert into check_log_test select cdate,h,(case when pv_pc<=@tv then 1 else 0 end),pv_pc from desktop_test where cdate=@newdate and h=@newh $$
DELIMITER ;
上面是写的触发器
一直提示1109,unknown table 'new' in field list sql statement 展开
1个回答
展开全部
USE `test`;
DELIMITER $$
DROP TRIGGER IF EXISTS test.desktop_test_AFTER_INSERT$$
USE `test`$$
CREATE DEFINER = CURRENT_USER TRIGGER `test`.`desktop_test_AFTER_INSERT` AFTER INSERT ON `desktop_test` FOR EACH ROW
begin
set @tv=1000 ;
set @newdate=new.cdate ;
set @newh=new.h ;
insert into check_log_test select cdate,h,(case when pv_pc<=@tv then 1 else 0 end),pv_pc from desktop_test where cdate=@newdate and h=@newh ;
end;
DELIMITER ;
DELIMITER $$
DROP TRIGGER IF EXISTS test.desktop_test_AFTER_INSERT$$
USE `test`$$
CREATE DEFINER = CURRENT_USER TRIGGER `test`.`desktop_test_AFTER_INSERT` AFTER INSERT ON `desktop_test` FOR EACH ROW
begin
set @tv=1000 ;
set @newdate=new.cdate ;
set @newh=new.h ;
insert into check_log_test select cdate,h,(case when pv_pc<=@tv then 1 else 0 end),pv_pc from desktop_test where cdate=@newdate and h=@newh ;
end;
DELIMITER ;
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询