我试图创建一个程序,但它得到了一个错误。 您的SQL语法有错误;查看与您的MySQL服务器版本相对应的手册,以获得在''附近使用的正确语法。在第4行。
第4行是" INSERT INTO TB ...."
DROP PROCEDURE IF EXISTS simpleproc;
CREATE PROCEDURE simpleproc (IN p_cd_empresa INT, IN p_cd_servico INT, IN p_cd_concessionaria VARCHAR (100))
BEGIN
IF p_cd_servico = 1 OR p_cd_servico = 3 OR p_cd_concessionaria = 'GESTAO' THEN
INSERT INTO TB_EMPRESA_IMPORTAR VALUES (p_cd_empresa, p_cd_servico, p_cd_concessionaria);
END IF;
END;
答案 0 :(得分:0)
对于多语句程序/函数,您忘记为;
添加另一个分隔符。
DELIMITER $$
DROP PROCEDURE IF EXISTS simpleproc;
CREATE PROCEDURE simpleproc (IN p_cd_empresa INT, IN p_cd_servico INT, IN p_cd_concessionaria VARCHAR (100))
BEGIN
IF p_cd_servico = 1 OR p_cd_servico = 3 OR p_cd_concessionaria = 'GESTAO' THEN
INSERT INTO TB_EMPRESA_IMPORTAR VALUES (p_cd_empresa, p_cd_servico, p_cd_concessionaria);
END IF;
END;
DELIMITER ;