如何在 postgres 8.2 中使用数组作为输入参数编写函数
How to write a function using arrays as input parameter in postgres 8.2
我是 Postgres 的新手,希望帮助我编写以数组作为输入参数的函数。我正在使用 SSRS 报告的功能,并希望添加多选功能
CREATE OR REPLACE FUNCTION foo(facid bigint, dptname text[])
RETURNS SETOF tmpdb AS
$BODY$
select * from tblitem
where dptname = and facid =
$BODY$
LANGUAGE sql VOLATILE;
在dptname 中您可以选择连衣裙或鞋子,但想显示选择两者的结果集。
由于版本原因,VARIADIC 不是一个选项。
CREATE OR REPLACE FUNCTION foo(facid bigint, dptname text[])
RETURNS SETOF <b>tblitem</b> AS
$BODY$
select * from tblitem
where facid =
and <b>dptname = ANY()</b>
$BODY$
LANGUAGE sql STABLE;
ANY
should work in Postgres 8.2.
- 函数可以
STABLE
。
- 当你
SELECT * FROM tblitem
时,函数应该returnSETOF tblitem
.
我是 Postgres 的新手,希望帮助我编写以数组作为输入参数的函数。我正在使用 SSRS 报告的功能,并希望添加多选功能
CREATE OR REPLACE FUNCTION foo(facid bigint, dptname text[])
RETURNS SETOF tmpdb AS
$BODY$
select * from tblitem
where dptname = and facid =
$BODY$
LANGUAGE sql VOLATILE;
在dptname 中您可以选择连衣裙或鞋子,但想显示选择两者的结果集。 由于版本原因,VARIADIC 不是一个选项。
CREATE OR REPLACE FUNCTION foo(facid bigint, dptname text[])
RETURNS SETOF <b>tblitem</b> AS
$BODY$
select * from tblitem
where facid =
and <b>dptname = ANY()</b>
$BODY$
LANGUAGE sql STABLE;
ANY
should work in Postgres 8.2.- 函数可以
STABLE
。 - 当你
SELECT * FROM tblitem
时,函数应该returnSETOF tblitem
.