Syntax error in MySQL procedure

0

I am trying to create a Procedure in MySQL and it is returning Syntax error. Here is my code for review:

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 anyone help me?

    
asked by anonymous 08.07.2015 / 16:28

1 answer

0

Try to separate $$ from END and ; from DELIMITER at the end of the statement.

END $$
DELIMITER ;

Without the space you say that these characters are part of the command and this may be causing the error.

    
08.07.2015 / 19:54