我有一个函数接受两个参数,从表中返回一些数据。想要将返回的行插入另一个函数中的临时表(具有与函数输出相同的结构)。
这样试过:
CREATE TEMP TABLE tmp1 (col1 int, col2 int) ON COMMIT DROP;
WITH x as (select function_name(p1, p2))
insert into tmp1 select * from x;
函数RETURNS TABLE(val1 integer, val2 integer)
选择不起作用。
ERROR: column "col1" is of type integer but expression is of type record
HINT: You will need to rewrite or cast the expression.
我该怎么办?
最佳答案
这样呢?..
insert into tmp1 select * from function_name(p1, p2);
关于postgresql - 如何将集合返回函数的输出插入到表中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31045041/