J. G. J. G. - 5 months ago 9
SQL Question

Mysql syntax error with stored procedure (workbench)

Ok so this is my current code

delimiter //

Create procedure addFish(in_color varchar(45), in_pattern varchar(45))
BEGIN
INSERT INTO ZenFish
(`ZenColorsID`,`Pattern`, `Hatched` )
VALUES
(
(select idZenColors from ZenColors where ColorName = in_color),
in_pattern,
CURRENT_TIMESTAMP()
);
END

delimiter ;


It does NOTHING when I press run in mysql workbench. Before I added the delimiter marks it at least gave me a syntax error. Adding delimiter lines seems to be what everyone else on stackoverflow was told to do with this problem, so I did it and now... just nothing happens when I press run, or select it all and press run, or run this statement. De nada.

Answer

you have small issue on your end tag

delimiter $$

Create procedure addFish(in_color varchar(45), in_pattern varchar(45))
BEGIN
INSERT INTO ZenFish
(`ZenColorsID`,`Pattern`, `Hatched`     )
VALUES
(
(select idZenColors from ZenColors where ColorName = in_color),
in_pattern,
CURRENT_TIMESTAMP()
);
END$$

delimiter ;

try this