我需要从模式中获取表名,除了一些表
CREATE OR REPLACE FUNCTION func(unnecessary_tables TEXT)
returns void
as $$
begin
EXECUTE 'SELECT table_name FROM information_schema.tables
WHERE
table_schema=''public''
AND
table_name NOT IN( $1 )
' USING unnecessary_tables
--here execute retrieved result, etc ...
end;
$$language plpgsql
然后调用函数
select func('table1'',''table2');
这不起作用并返回 table1
结果table2
。
问题是:如何将文本参数传递给存储函数,对于IN
运算符?