I have a function taking two parameters, returns some data from tables. Want to insert the returned rows to a temp table (with same structure as function output) in another function.
Tried like this:
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;
The function RETURNS TABLE(val1 integer, val2 integer)
The select does not work.
ERROR: column "col1" is of type integer but expression is of type record
HINT: You will need to rewrite or cast the expression.
What shall I do?
and this way?..