我执行存储过程时收到错误

时间:2013-08-02 07:21:58

标签: mysql sql stored-procedures

我收到以下错误

  

1064 - 您的SQL语法出错;检查与MySQL服务器版本对应的手册,以获得正确的语法   靠近'作为BEGIN SELECT计数(CustomerFeed.overall)as sat FROM   第2行的ContactCenter L'

当我运行此声明时。

DELIMITER //
CREATE PROCEDURE GetAllProducts2(IN location VARCHAR(100),
                                 IN start1   TIMESTAMP,
                                 IN end1     TIMESTAMP)
BEGIN
  SELECT count(CustomerFeed.overall) AS sat
  FROM   ContactCenter
         LEFT JOIN CustomerFeed
           ON ContactCenter.callId = CustomerFeed.callId
  WHERE  date(ContactCenter.callClose) BETWEEN start1 AND end1
         AND ContactCenter.callStatus = 'Close'
         AND CustomerFeed.overall IN ( 1, 2 )
         AND ContactCenter.location = location
         AND ContactCenter.gNum != '';
       END //
DELIMITER;

1 个答案:

答案 0 :(得分:0)

不要在MySql的stored procedure definition中使用AS关键字。所以删除它。

DELIMITER //
CREATE PROCEDURE GetAllProducts2(IN location varchar(100),
                                 IN start timestamp,
                                 IN end timestamp)
BEGIN
   ...
END //
DELIMITER ;