SQL,缺少结尾,但是为什么呢? [英] SQL, missing end, but why?
本文介绍了SQL,缺少结尾,但是为什么呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的SQL过程有问题. MySQLWorkbench建议我错过第一个SET的结尾",但不要错过第二个SET的结尾".我不知道为什么.
I have an issue with my SQL procedure. MySQLWorkbench advise me that it miss 'end' to my first SET, but not for the second. I don't know why.
DELIMITER $
drop procedure if exists pay10percent$
create procedure pay10percent(IN montant decimal(9,2),IN idResa INT(5))
begin
declare circuitid INT;
SET circuitid = (
SELECT IDCIRCUIT
FROM RESERVATION
WHERE IDRESERVATION=idResa
);
declare montantCircuit decimal(9,2);
SET montantCircuit = (SELECT PRIX FROM CIRCUIT WHERE IDCIRCUIT=circuitid);
end;
$
DELIMITER ;
谢谢.
推荐答案
使用SET
之前必须声明所有变量.或者,您可以删除SET
并将该子查询用作默认值:
You must declare all the variables before using SET
. Alternatively, you can drop SET
and use that subquery as a default value:
declare circuitid INT DEFAULT (
SELECT IDCIRCUIT
FROM RESERVATION
WHERE IDRESERVATION=idResa
);
这篇关于SQL,缺少结尾,但是为什么呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文