Error in MySQL Procedure

0

I am trying to perform the following stored procedure

CREATE PROCEDURE insert_trabajador
(
IN rut VARCHAR(12),
IN nom VARCHAR(50),
IN est VARCHAR(50),
IN sueldo INT(11)
)
BEGIN
INSERT INTO trabajadores
(
rut,
nombre,
estado,
sueldo_base
) 
VALUES
(
rut,
nom,
est,
sueldo
);
END

But I get this error that would be );

  

1064 - Something is wrong in its syntax near '' on line 22

    
asked by Isaac Andrés 08.11.2017 в 21:57
source

1 answer

1

By default, MySQL considers that the semicolon is a delimiter. If you do not redifine that, MySQL considers that ); is the end of your procedure.

Therefore, you should usually surround the definition of your procedure in this way:

delimiter //

CREATE PROCEDURE insert_trabajador
(
IN rut VARCHAR(12),
IN nom VARCHAR(50),
IN est VARCHAR(50),
IN sueldo INT(11)
)
BEGIN
INSERT INTO trabajadores
(
rut,
nombre,
estado,
sueldo_base
) 
VALUES
(
rut,
nom,
est,
sueldo
);
END//

delimiter ;
    
answered by 08.11.2017 / 22:04
source