create PROCEDURE PR_Credit_Total(
in newidpiece int,
in newnpiece bigint,
in newnop varchar(60),
in newdateengagement date,
in newdatefacture date,
in newlocalité varchar(50),
in newtournee int,
in newnpolice bigint,
in newservice varchar(20),
in newmontant float,
in newecheance varchar(7),
in newcreated varchar(25),
in eventvarchar(100)
)
BEGIN
set @total=(SELECT sum(Total_Crédit) from credit_electricité) ;
if event=='ajouter'
and newtournee is null
THEN
if @total-newmontant>=0
INSERT into vignetteoneep VALUES(newidpiece,newnpiece,newnop,newdateengagement,
newdatefacture,newlocalité,newtournee,newnpolice,newservice,newmontant,newecheance,newcreated);
then
UPDATE credit_electricité set Total_Crédit=Total_Crédit-newmontant;
end if;
end if;
结束
2条答案
按热度按时间3npbholx1#
yh2wf1be2#
以下是要修复的语法错误列表
在eventvarchar(100)中缺少空格,应该在event varchar(100)中,但event是关键字,最好避免
如果event=='ajouter'在mysql中为空安全等于〈=〉,那么应该是如果event〈=〉'ajouter',但是=可以
第二个如果没有,那么不清楚插入和更新是否应该是相同条件的一部分,但我怀疑不是
您可能需要设置分隔符