为什么在 Firebird 中创建存储过程时出现 SQLSyntaxErrorException?

Why am I getting SQLSyntaxErrorException creating a stored procedure in Firebird?

我不确定为什么会在此处出现错误。我只是想创建一个执行 select.

的存储过程
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 error code = -104; Token unknown - line 9, column 1; END

所以我加了一个分号:

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 error code = -104; Token unknown - line 8, column 34; ;

有什么想法吗?

你应该阅读 Language Reference。在 PSQL 子句中,“INTO”对于 SELECT 是强制性的。