I'm an absolute noob and couldn't find the answer to this one.
How can I add the result into a temporary table?
Perhaps you guys have some tips for me to improve my code as well?
I created a function here with cursors through the results. But I need to:
drop function if exists non_married_presidents();
create or replace function non_married_presidents()
returns varchar as $$
declare
c_emp cursor for
select name, birth_year from president
where id not in(select pres_id from pres_marriage);
begin
for emp in c_emp loop
raise notice 'name: %, birth_year: %', emp.name, emp.birth_year;
end loop;
end;
$$language plpgsql;
Call:
select non_married_presidents();