【问题标题】:Can not call a Mysql Stored Procedure more than one time, exists in the same sql file不能多次调用一个Mysql存储过程,存在于同一个sql文件中
【发布时间】:2016-08-28 03:24:40
【问题描述】:

我的存储过程是

DELIMITER //
CREATE Add_Template(
        template_id_             VARCHAR(20),
        file_name_               VARCHAR(100),
        template_description_    VARCHAR(500))
BEGIN
    INSERT INTO application_template_tab VALUES(template_id_,file_name_,template_description_);
END//

我在同一个 .sql 文件中按如下方式调用此过程

call Add_Template('ICT','frmIct.jsp','Information Communication Technology');
call Add_Template('Bac_Bus_Adm','frmBusAdm.jsp','Bachelor of Business Administration');
  1. 将这些过程调用放在一个单独的文件中并在执行存储过程后执行它也可以正常工作。
  2. 在存储过程之后只调用一次也可以正常工作

但是在存储过程之后的同一个文件中,当我添加第二个调用时,它给了我以下错误,

错误代码 1064,SQL 状态 42000:您的 SQL 中有错误 句法;检查与您的 MySQL 服务器版本相对应的手册 在 'call 附近使用正确的语法 Add_Template('Bac_Bus_Adm','frmBusAdm.jsp','Bachel' 在第 2 行

注意:- 建表脚本

CREATE TABLE IF NOT EXISTS application_template_tab(
                    app_template_id          VARCHAR(20)    NOT NULL,
                    form_name                VARCHAR(100)   NOT NULL,
                    template_desc            VARCHAR(500)   NOT NULL,
PRIMARY KEY (app_template_id));

【问题讨论】:

    标签: mysql stored-procedures


    【解决方案1】:

    在您的文件中,您将使用DELIMITER // 更改默认值; 的语句分隔符。

    这是客户端正确处理过程声明等复杂语句所必需的。

    但错误表明您没有将其设置回默认值。

    END // 之后但在CALL 语句之前,你需要这个:

    DELIMITER ;  -- note there is a space required before the ;
    

    【讨论】:

      猜你喜欢
      • 2015-01-10
      • 2019-02-09
      • 2021-09-24
      • 1970-01-01
      • 1970-01-01
      • 2011-05-05
      • 2021-01-26
      • 2013-03-04
      相关资源
      最近更新 更多