我不知道为什么这里会出现错误。我只是想创建一个执行选择的存储过程。
CREATE PROCEDURE spCustomerOrders(cust_id varchar(10))
AS
BEGIN
SELECT c.Customer_ID, c.Company_Name, o.ID Order_ID,
o.Name AS Description, o.Date_Paid, o.Created AS DateCreated, o.PAID
FROM ORDERS o
JOIN Customers c ON o.Customer_ID = c.Customer_ID
WHERE c.Customer_ID = :cust_id
END
当我尝试这个时,我得到
SQL错误代码=-104;令牌未知-第9行,第1列;结束
所以我添加了一个分号:
CREATE PROCEDURE spCustomerOrders(cust_id varchar(10))
AS
BEGIN
SELECT c.Customer_ID, c.Company_Name, o.ID Order_ID,
o.Name AS Description, o.Date_Paid, o.Created AS DateCreated, o.PAID
FROM ORDERS o
JOIN Customers c ON o.Customer_ID = c.Customer_ID
WHERE c.Customer_ID = :cust_id;
END
我得到:
SQL错误代码=-104;令牌未知-第8行,第34列;
有什么想法吗?
您应该阅读《语言参考》。在PSQL子句";INTO";对于SELECTs是强制性的。