我在 MySql(navicat) 中有以下存储过程,但是当我添加 if st 时,我需要在更新操作后测试RefrenceCount 。在更新声明之后。发生语法错误
CREATE PROCEDURE `SP_IncDecReferenceCount`(pReferenceID int,pIncValue int)
BEGIN
update filesrefrences
set
filesrefrences.RefrenceCount= filesrefrences.RefrenceCount+pIncValue
where
filesrefrences.ReferenceID= pReferenceID;
IF Not EXISTS(SELECT * from filesrefrences where filesrefrences.ReferenceID= pReferenceID and filesrefrences.RefrenceCount>0) then
DELETE from filesrefrences WHERE filesrefrences.ReferenceID = pReferenceID;
end if
END
[Err] 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 11