【发布时间】:2013-05-11 05:08:17
【问题描述】:
我有一个视图由两个表组成。假设表 TableA 和表 TableB。
现在表 A 有大约 20 列,表 B 有 4 列。
TableA (
id datatype,
uid datatype,
.
.
.
18 more);
TableB (
id datatype,
uid datatype,
a_id datatype,
amount datatype,
CONSTRAINT tablea_tableb_fkey FOREIGN KEY (a_id)
REFERENCES tablea (id) MATCH SIMPLE
ON UPDATE RESTRICT ON DELETE RESTRICT,
);
所以 TableA 和 TableB 之间是一对多的关系。现在我把视图写成如下...
CREATE OR REPLACE VIEW AB AS
SELECT a.id, a.uid, ..., array_agg(b.amount) AS amounts
FROM TableA a
JOIN TableB b ON a.id = b.a_id
GROUP BY i.id;
现在我想为这个视图编写插入规则,我正在编写一个辅助函数。该函数需要大约 18 个参数(id 除外,uid 具有默认值)用于插入 TableA 和 1 个参数,即 TableB 的数组。
所以函数的总参数是 19。我想知道在postgresql 中我可以传递给函数的最大参数数是多少?发送这么多参数是否明智?有没有更好的方法来为这么多参数编写函数?
【问题讨论】:
-
检查我在 postgresql 9.2 中使用的最大函数参数。 select * from pg_settings where name='max_function_args';