如何做一个firebird SP,SELECT * FROM“TABLE”?

时间:2009-11-23 13:58:07

标签: sql stored-procedures select firebird

我正在从SQL Server迁移到Firebird。

在SQL Server中

CREATE PROCEDURE Departments_GetAll
AS
    SELECT * FROM Departments

我在Firebird中尝试

CREATE PROCEDURE DEPARTMENTS_DELETEALL
AS 
BEGIN
  SELECT * FROM "Departments";
END^

SET TERM ; ^

但这不起作用。

它返回错误“SQL Code -104”

1 个答案:

答案 0 :(得分:10)

存储过程需要返回参数和suspend命令才能返回多行。

CREATE PROCEDURE DEPARTMENTS_GET_ALL
returns(id integer, name varchar(100))
AS 
BEGIN
  FOR SELECT id, name
  FROM "Departments"
  into :id, :name do
  BEGIN
    SUSPEND;
  END
END^

SET TERM ; ^