我在stored procedure
中有以下mysql
。
CREATE DEFINER=`cefcy`@`localhost` PROCEDURE `insert_eD_medication` (IN `p_id` INT(11), IN `strength` VARCHAR(45), IN `unit_id` INT(11), IN `package_no` VARCHAR(45), IN `medicinal_product_package` VARCHAR(45), IN `pharmaceutical_dose_form_id` INT(11), IN `brandName` VARCHAR(45), IN `route_of_administration_id` INT(11), IN `date_of_dispense` DATE, IN `substitution` VARCHAR(45), IN `stat` TINYINT(4), IN `v_id` INT(11))
NO SQL
BEGIN
INSERT INTO `medication_dispensation_mapping` (`patient_id`, `strength`, `unit_id`, `package_no`, `medicinal_product_package`, `pharmaceutical_dose_form_id`,`brandName`, `route_of_administration_id`, `date_of_dispense_medicine_event`, `substitution`, `status`, `version_id`)
VALUES (p_id, strength, unit_id, package_no, medicinal_product_package, pharmaceutical_dose_form_id, brandName, route_of_administration_id, date_of_dispense, substitution, stat, v_id);
END
当我尝试运行它时,出现以下错误:
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 5
你能帮我吗?
答案 0 :(得分:1)
感谢@DanFromGermany评论和建议的How can I fix MySQL error #1064?,我找到了解决方案。
即使我没有更改必须在stored procedure
中定义的定界符。
因此,我的正确代码是:
DELIMITER $$
CREATE DEFINER=`cefcy`@`localhost` PROCEDURE `insert_eD_medication` (IN `p_id` INT(11), IN `strength` VARCHAR(45), IN `unit_id` INT(11), IN `package_no` VARCHAR(45), IN `medicinal_product_package` VARCHAR(45), IN `pharmaceutical_dose_form_id` INT(11), IN `brandName` VARCHAR(45), IN `route_of_administration_id` INT(11), IN `date_of_dispense` DATE, IN `substitution` VARCHAR(45), IN `stat` TINYINT(4), IN `v_id` INT(11))
NO SQL
BEGIN
INSERT INTO `medication_dispensation_mapping` (`patient_id`, `strength`, `unit_id`, `package_no`, `medicinal_product_package`, `pharmaceutical_dose_form_id`,`brandName`, `route_of_administration_id`, `date_of_dispense_medicinal_event`, `substitution`, `status`, `version_id`)
VALUES (p_id, strength, unit_id, package_no, medicinal_product_package, pharmaceutical_dose_form_id, brandName, route_of_administration_id, date_of_dispense, substitution, stat, v_id);
END;
$$
DELIMITER ;