When I using query to select values to temp table like this:
drop table if exists tTemp;
select tt.id, tt.name
into tTemp
from test.TestTable tt
It’s work great. But when I using this construction in function I have this error:
[42601] ERROR: "tTemp" is not a known variableq
Why this construction don’t work in function?
2
Answers
its may be work :
Use the standard compliant CRATE TABLE AS SELECT instead of the discouraged select … into to avoid the ambiguity between storing the result of a query into a PL/pgSQL variable and creating a new table:
This is one of the reasons the manual recommends to use CREATE TABLE AS instead of select into