PostgreSQL - use custom loopback select

0

I have a function that does a select like this:

SELECT a.nome, b.email into nome, email FROM tabela1 a
INNER JOIN tabela2 b ON b.fk = a.fk

Is there any way to create a "temporary table" that I can temporarily store the various possible returns of that function and use them inside a loop like the following?

LOOP
    --faz alguma coisa as variáveis nome e email
END LOOP

Edit - problem solved, solution in answers

    
asked by anonymous 23.11.2018 / 13:22

1 answer

0

I was able to resolve it as follows:

FOR nome, email IN 
(SELECT a.nome, b.email into nome, email FROM tabela1 a
INNER JOIN tabela2 b ON b.fk = a.fk)
LOOP
-- faz alguma coisa com as variáveis nome e email
END LOOP
    
23.11.2018 / 14:12