语法错误1064 - insert不作为存储过程工作

时间:2015-02-20 16:32:19

标签: mysql stored-procedures

我创建了一个作为sql语句工作的插入查询,但是当我尝试通过MYSQL Administrator将其作为存储过程实现时,我得到MYSQL错误1064“你的SQL语法有错误....附近DELIMITER / / DROP PROCEDURE“ 这是声明:

DELIMITER //
DROP PROCEDURE IF EXISTS `LoadRecs_proc`;

CREATE DEFINER=`root`@`%` PROCEDURE `LoadRecs_proc`()
BEGIN

INSERT into Assignments_tbl (AccountId, ActivityID, ActivityDate, pname, CustomerName, GroupName, ProviderName, Contact, Phone, Extension, Selected, Closed)
Select
  tbl_ca.AccountId,
  tbl_ca.ActivityID,
  tbl_ca.ActivityDate,
  Concat_Ws(', ', tblcust.`Last Name`, tblcust.`First Name`) As pname,
  cust.CustomerName,
  tbl_cp.GroupName,
  tblproviders.ProviderName,
  tblproviders.Contact,
  tblproviders.Phone,
  tblproviders.Extension,
  0 As Selected,
  0 As Closed
From
  (((tbl_ca Inner Join
  (tbl_cp Inner Join
  cust.On tbl_cp.UID= cust.UID)
On tbl_ca.AccountId = tbl_cp.AccountId) Inner Join
  tblproviders On tbl_ca.ProviderId = tblproviders.ProviderId)
  Inner Join
  cust On tbl_cp.CustomerId = cust.CustomerId)
  Left Join
  FollowupAssignments_tbl On tbl_ca.ActivityDate =
    FollowupAssignments_tbl.ActivityDate And
tbl_ca.ActivityID =
FollowupAssignments_tbl.ActivityID And
tbl_ca.AccountId = FollowupAssignments_tbl.AccountId
Where
  tbl_ca.ActivityID = 76 And
  tbl_ca.ResponseDate Is Null And
  tbl_cp.Status = "Active" And
  tbl_cp.CustomerId = 33  And
  FollowupAssignments_tbl.AccountId Is Null And
  FollowupAssignments_tbl.ActivityID Is Null And
  FollowupAssignments_tbl.ActivityDate Is Null
  ;

END//
DELIMITER ;

2 个答案:

答案 0 :(得分:0)

将第一个交换为线条。您需要在为DROP PROCEDURE语句设置分隔符之前运行CREATE PROCEDURE

由此:

DELIMITER //
DROP PROCEDURE IF EXISTS `LoadRecs_proc`;

对此:

DROP PROCEDURE IF EXISTS `LoadRecs_proc`;
DELIMITER //

答案 1 :(得分:0)

它不喜欢DROP PROCEDURE。我消除了它,它运行。它也不是IF EXISTS。 这是MYSQL 5.7.3-m13 64位社区版。

感谢您的帮助。