Firebird存储过程语法 - 拒绝;

时间:2011-03-21 10:45:13

标签: stored-procedures syntax firebird

我正在尝试在Firebird中创建以下存储过程但我必须得到错误的语法,因为它抱怨如下:

Statement #3:
SQL error code = -104
Token unknown - line 23, column 46
;

存储过程本身如下 - 我做错了什么?

SET AUTODDL OFF;
SET TERM ^ ;

CREATE PROCEDURE SP_KPI
(
  STAFFID INTEGER,
  FROM_DATE DATE,
  TO_DATE DATE
)
RETURNS
(
  FORENAME VARCHAR(50),
  SURNAME VARCHAR(50),
  STATUSNAME VARCHAR(50),
  STATUS_COUNT INTEGER
)
AS
BEGIN
   SELECT s.forename, s.surname, v2.statusname, count(v2.statusname) as STATUS_COUNT
     FROM Vacconthist v
     JOIN Staff s ON v.staffid=s.staffid
     JOIN Vacstatus v2 ON v2.statusid=v.status
    WHERE (s.staffid = 867) AND (v.LASTUPDATE BETWEEN '01-Jan-2011' AND '08-Mar-2011') AND (v.status > 9 AND v.status < 99999)
GROUP BY s.forename, s.surname, v2.statusname;
END
^

SET TERM ; ^
COMMIT WORK;

1 个答案:

答案 0 :(得分:1)

你错过了INTO条款!选择应该如下:

   SELECT s.forename, s.surname, v2.statusname, count(v2.statusname) as STATUS_COUNT
     FROM Vacconthist v
     JOIN Staff s ON v.staffid=s.staffid
     JOIN Vacstatus v2 ON v2.statusid=v.status
    WHERE (s.staffid = 867) AND (v.LASTUPDATE BETWEEN '01-Jan-2011' AND '08-Mar-2011') AND (v.status > 9 AND v.status < 99999)
GROUP BY s.forename, s.surname, v2.statusname INTO :FORENAME, :SURNAME, :STATUSNAME, :STATUS_COUNT;