有2个表barcode和itbarcode,表barcode中有字段a_barcode,b_barcode我想做个触发器当我update表barcode时(修改a_barcode,b_barcode的值),触发事件 检测我刚输入的a_barcode,b_barcode的值是否在表itbarcode字段barcode里面,如果不存在就恢复原来的值,即不更新数据。
或者有其他方法,我该怎么做。谢谢
或者有其他方法,我该怎么做。谢谢
set @ee=0;
select count(*) into @ee from itbarcode where new.a_barcode=barcode or new.b_barcode=barcode;
if @ee>=1 then
set new.a_barcode=old.a_barcode;
set new.b_barcode=old.b_barcode;
end if
MySQL 中如何在触发器里中断记录的插入或更新?
for each row begin
set @ee=0;
select count(*) into @ee from itbarcode where new.a_barcode=barcode or new.b_barcode=barcode;
if @ee>=1 then
set new.a_barcode=old.a_barcode;
set new.b_barcode=old.b_barcode;
end if
end;
错误提示: 执行错误 # 1064. 从数据库的响应: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near
'end' at line 9怎么我贴的图 看不到呢 就我看的到?