0
I am trying to create a Procedure in Mysql and is returning Syntax error. Follow my code for analysis:
DELIMITER $$
CREATE PROCEDURE CalculaIdadeCP (IN cpcaminhaoid INT)
BEGIN
DECLARE DataEnsaio,DataMoldagem DATETIME;
/*CORPO DO PROCEDIMENTO*/
SET DataEnsaio = (
SELECT
da.DataEnsaio
FROM dadoscpconcreto AS da INNER JOIN cpcaminhao AS cp ON
da.CpCaminhaoId = cp.CPCaminhaoId
WHERE cp.CPCaminhaoId = cpcaminhaoid
);
SET DataMoldagem = (
SELECT
cp.DataMoldagem
FROM dadoscpconcreto AS da INNER JOIN cpcaminhao AS cp ON
da.CpCaminhaoId = cp.CPCaminhaoId
WHERE cp.CPCaminhaoId = cpcaminhaoid
);
IF DataEnsaio IS NOT NULL THEN
BEGIN
SET (
SELECT
da.IdadeRompimento
FROM dadoscpconcreto AS da INNER JOIN cpcaminhao AS cp ON
da.CpCaminhaoId = cp.CPCaminhaoId
WHERE cp.CPCaminhaoId = cpcaminhaoid
) = SELECT DATEDIFF(DataEnsaio,DataMoldagem);
END;
END IF;
END$$
DELIMITER;
Can someone help me ?
Continue with the mistake !
– Raphael Prado de Oliveira
Paste the code there for me to put here in my SQL.
– Diego Souza
What does that mean
IF DataEnsaio
? You’re giving aSET
on what ? And that= SELECT
at the end of it ?– Diego Souza
I am giving a Set of the difference of the two Dates on the return of the SELECT (da.Idaderompimento) . But I only do this if the Date is not null
– Raphael Prado de Oliveira