如何将整数数组传递给IN子句?

Tim*_*kov 4 sql postgresql

我想将一个整数数组从postgresql函数的输入参数传递给sql IN子句.

进入什么以及如何转换这样的数组?

rsc*_*rsc 5

我最近遇到了同样的问题.

看这里:

http://postgresql.1045698.n5.nabble.com/Using-PL-pgSQL-text-argument-in-IN-INT-INT-clause-re-post-td3235644.html

希望能帮助到你.

这是一个示例函数:

CREATE OR REPLACE FUNCTION "GetSetOfObjects"(ids text)
  RETURNS SETOF record AS
$BODY$select *
from objects
where id = any(string_to_array($1,',')::integer[]);$BODY$
  LANGUAGE sql IMMUTABLE
Run Code Online (Sandbox Code Playgroud)