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 ;
Thanks.
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
);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With