gpt4 book ai didi

postgresql - 如何将集合返回函数的输出插入到表中

转载 作者:行者123 更新时间:2023-11-29 11:43:01 25 4
gpt4 key购买 nike

我有一个函数接受两个参数,从表中返回一些数据。想要将返回的行插入另一个函数中的临时表(具有与函数输出相同的结构)。

这样试过:

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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com