I am trying to create a temporary table in my stored function in Postgresql. The language I am using is "plpgsql".
When I run the stored function it throws an SQL Error [42P01].
Exact Error
: "Query execution failed . Reason:
SQL Error [42P01]: ERROR: relation "temp_table" does .
not exist"
CREATE OR REPLACE FUNCTION public.sp_str_dsl_lp_ung(x int8)
RETURNS integer
LANGUAGE plpgsql volatile
AS $function$
declare
--variables
variab int :=0;
begin
CREATE temporary TABLE temp_table (a int8, b int8) ;
insert into temp_table (a,b) select (a,b) from existing_table;
end
$function$
I want to create a temp table to store some records temporarily.