Sunday 13 August 2023

How To Use/Create Temporary/Temp Tables In PostgreSQL Procedure/Function...




Only 3.9% of viewers are subscribing to my channel 😓.
I request you to please give click on Subscribe button.
It really helps me grow 😢.

Please Like, Comment, and Subscribe to my channel. ❤



-- Global Temporary Tables Usage In PostgreSQL Procedure/Function
-- How To Use Temporary Tables In PostgreSQL Procedure/Function
create or replace procedure temp_tables_proc()
    language plpgsql
    as $$
declare
v_count numeric(10);
begin
create temp table temp_tables(name character varying(100)) on commit preserve rows;
insert into temp_tables values ('Mumbai');
insert into temp_tables values ('Pune');
select count(*) into v_count from temp_tables;
raise notice 'Records : %', v_count;
drop table temp_tables;

exception
when others then
raise notice 'Error : %', substr (sqlerrm, 1, 100);
end;
$$;

call temp_tables_proc();

No comments:

Post a Comment