我的 SQL 过程有问题。 MySQLWorkbench 告诉我它错过了我的第一个 SET 的“结束”,但第二个没有。我不知道为什么。
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
并将该子查询用作默认值:
declare circuitid INT DEFAULT (
SELECT IDCIRCUIT
FROM RESERVATION
WHERE IDRESERVATION=idResa
);
关于mysql - SQL,缺少结尾,但为什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30917086/