Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/function/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在PostgreSql中,如何在函数或存储过程中同时返回表和输出参数?_Postgresql_Function_Stored Procedures_Datatables_Return - Fatal编程技术网

在PostgreSql中,如何在函数或存储过程中同时返回表和输出参数?

在PostgreSql中,如何在函数或存储过程中同时返回表和输出参数?,postgresql,function,stored-procedures,datatables,return,Postgresql,Function,Stored Procedures,Datatables,Return,我正在尝试从MS Sql Server迁移到PostgreSql。如果创建函数,则不能使用out和inout参数。若创建存储过程,则无法返回表。我不知道怎么做 总之,我想返回表并一起使用以inout参数 就像: CREATE or REPLACE FUNCTION public."test" (INOUT "x" integer, INOUT "y" text) RETURNS TABLE ( "id" integer, "filesize" character varying(36) )

我正在尝试从MS Sql Server迁移到PostgreSql。如果创建函数,则不能使用
out
inout
参数。若创建存储过程,则无法返回表。我不知道怎么做

总之,我想返回表并一起使用以
inout
参数

就像:

CREATE or REPLACE FUNCTION public."test" (INOUT "x" integer, INOUT "y" text)

RETURNS TABLE  (
"id" integer,
"filesize" character varying(36)
)
AS $$
 BEGIN
RETURN QUERY
SELECT * FROM    public."tbl_employees" ;

END;
$$ LANGUAGE plpgsql;

它可以是存储过程,我不知道怎么做。

很简单:你不能这么做。根据:
OUT
INOUT
参数不能与
返回表
注释一起使用。您有什么建议吗?在这种情况下,为什么需要返回x和y?在不了解细节的情况下,很难提出替代方案。您可以执行类似于
INOUT x integer、INOUT y text、INOUT refcursor
的操作,然后返回一个从表中选择的游标,但这非常难看。我将输出参数和表调到另一个位置。