Loop in pl / sql oracle

0

I want to know how to go through all the tuples that are stored in a table; how do I do this in PL / SQL Oracle ?

Thank you in advance!

    
asked by anonymous 28.04.2017 / 21:02

1 answer

1

I understand that you want to use a cursor . In PL/SQL you can do using FOR .
Suppose you have a table with the Code and Name fields, an example would look like this:

FOR i IN (SELECT Codigo, Nome FROM Tabela)
LOOP
    /*Aqui é possível ler cada campo da tupla usando a variável "i"*/
    DBMS_OUTPUT.PUT_LINE(i.Codigo||' '||i.Nome);
END LOOP;
    
28.04.2017 / 21:12