Thursday, March 8, 2018

PL/SQL - SELECT multiple rows

declare
          type party_id_type is table of hz_parties.party_id%type;
          type party_name_type is table of hz_parties.party_name%type;
           party_id_tab   party_id_type;
           party_name_tab party_name_type;
begin
     SELECT party_id,party_name
     BULK COLLECT INTO party_id_tab, party_name_tab
     FROM hz_parties;
   
    FOR i IN party_id_tab.FIRST..party_id_tab.LAST
    LOOP
       DBMS_OUTPUT.PUT_LINE ('party_id: '||party_id_tab(i));
       DBMS_OUTPUT.PUT_LINE ('party_name: '||party_name_tab(i));
    END LOOP;
end;

No comments:

Post a Comment