2016-03-23 41 views
0

我無法把握,爲什麼這是行不通的失敗,我有沒有問題工作的近similair的過程,但是這一次只是不斷拋出一個錯誤:MySQL的存儲過程在「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 'END' at line 36

DELIMITER // 
CREATE PROCEDURE FillCnsGroupWithRates 
(
    IN groupId INT(10) 
) 
BEGIN 
    SET @var1 = groupId; 
    INSERT INTO 
     cns_group_rates 
     (
      cns_id, 
      other_cns_id, 
      ppc, 
      pps, 
      max_price, 
      notes, 
      cns_group_id 
     ) 
    SELECT 
     cns_id, 
     other_cns_id, 
     ppc, 
     pps, 
     max_price, 
     notes, 
     @var1 
    FROM 
     cns_rates 
    WHERE 
     cns_id NOT LIKE '319%' 
    AND 
     client_id IS NULL 
    AND 
     subordinates IS NULL 
    AND 
     valid_from IS NULL 
END // 
DELIMITER ; 
+2

在END前添加';' –

回答

0

您查詢 年底忘記分號試試這個

DELIMITER // 
CREATE PROCEDURE FillCnsGroupWithRates 
(
    IN groupId INT(10) 
) 
BEGIN 
    SET @var1 = groupId; 
    INSERT INTO 
     cns_group_rates 
     (
      cns_id, 
      other_cns_id, 
      ppc, 
      pps, 
      max_price, 
      notes, 
      cns_group_id 
     ) 
    SELECT 
     cns_id, 
     other_cns_id, 
     ppc, 
     pps, 
     max_price, 
     notes, 
     @var1 
    FROM 
     cns_rates 
    WHERE 
     cns_id NOT LIKE '319%' 
    AND 
     client_id IS NULL 
    AND 
     subordinates IS NULL 
    AND 
     valid_from IS NULL; 
END // 
DELIMITER ; 
+0

不能相信我忽略了這一點,感謝您的快速回復,它現在可以工作 – Peter

1

您忘記分號結束上述

DELIMITER // 
CREATE PROCEDURE FillCnsGroupWithRates 
(
    IN groupId INT(10) 
) 
BEGIN 
    SET @var1 = groupId; 
    INSERT INTO 
     cns_group_rates 
     (
      cns_id, 
      other_cns_id, 
      ppc, 
      pps, 
      max_price, 
      notes, 
      cns_group_id 
     ) 
    SELECT 
     cns_id, 
     other_cns_id, 
     ppc, 
     pps, 
     max_price, 
     notes, 
     @var1 
    FROM 
     cns_rates 
    WHERE 
     cns_id NOT LIKE '319%' 
    AND 
     client_id IS NULL 
    AND 
     subordinates IS NULL 
    AND 
     valid_from IS NULL; 
END // 
DELIMITER ;