MySQL错误#2014-命令不同步;您现在不能在存储过程中运行此命令

时间:2018-11-22 13:45:52

标签: mysql stored-procedures phpmyadmin

我在stored procedure中有以下mysql

DELIMITER $$
CREATE DEFINER=`user`@`localhost` PROCEDURE `insert_patient`(IN `name` VARCHAR(45), IN `surname` VARCHAR(45), IN `middle_name` VARCHAR(45), IN `patient_gender` VARCHAR(15), IN `patient_weight` VARCHAR(15), IN `patient_height` VARCHAR(15), IN `patient_ethnic_origin` VARCHAR(45))
    NO SQL
BEGIN

BEGIN
INSERT
INTO
  patient(
    name,
    surname,
    middle_name
  )
VALUES(
  name,
  surname,
  middle_name
) ;
SELECT
  LAST_INSERT_ID() AS patient_local_id;
END;
BEGIN
INSERT
INTO
  demographics(
    patient_id,
    gender,
    weight,
    height,
    ethnic_origin
  )
VALUES(
  patient_local_id,
  patient_gender,
  patient_weight,
  patient_height,
  patient_ethnic_origin
) ;
END;
END$$
DELIMITER ;

当我尝试从phpmyadmin执行此存储过程时,出现以下错误:

Unrecognized keyword. (near "ON" at position 25)
SQL query: Edit Edit

SET FOREIGN_KEY_CHECKS = ON;

MySQL said: Documentation

#2014 - Commands out of sync; you can't run this command now

1 个答案:

答案 0 :(得分:0)

我找到了解决方案。在执行存储过程时,我选中了以下框。

enter image description here