Postgresql - use custom select return in loop

Asked

Viewed 49 times

0

I have a function that makes a select like that:

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 this function and use them within a loop like the following?

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

Edit - problem solved, solution in the answers

1 answer

0


I was able to solve it this way:

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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.