2012-03-19 50 views
0

我是新來創建MySQL中的程序,我知道如何在MSSQL中創建它們,但我不知道什麼是錯,它說Syntax Error Near ENDMySQL存儲過程顯示在語法錯誤

CREATE PROCEDURE GetNameByID(IN CustID INT) 
    BEGIN 
    SELECT * FROM Customers WHERE CustomerID = CustID 
    END 

回答

1

您的過程中的查詢需要一個分號:

CREATE PROCEDURE GetNameByID(IN CustID INT) 
    BEGIN 
    SELECT * FROM Customers WHERE CustomerID = CustID; 
    END 

您可能還需要將分隔符設置爲某些內容。該MySQL documentation做到這一點:

DELIMITER // 

CREATE PROCEDURE GetNameByID(IN CustID INT) 
    BEGIN 
    SELECT * FROM Customers WHERE CustomerID = CustID; 
    END// 

(但顯然不是你的查詢)

0

你缺少的;在選擇聲明結束時