RSS Feed

PL/SQL Tables







Nested tablesVarraysIndex-by-tables
Declare
Cursor name_cur IS
Select last_name
From student
Where rownum <= 10;

Type last_name_type
Is Table Of
student.last_name%Type;
last_name_tab
last_name_type :=
last_name_type();
v_counter INTEGER := 0;
BEGIN
FOR name_rec IN name_cur
LOOP
v_counter := v_counter + 1;
last_name_tab.EXTEND;
last_name_tab(v_counter):=
name_rec.last_name;

Dbms_Output.Put_Line
('last_name('||v_counter||'):
'||
last_name_tab(v_counter));
END LOOP;
END;

Declare
Cursor name_cur IS
Select last_name
From student
Where rownum <= 10;

Type last_name_type
Is Table Of
student.last_name%TYPE
Index By
Binary_Integer;
last_name_tab
last_name_type;
v_counter INTEGER := 0;

Begin
For
name_rec IN name_cur
Loop v_counter :=
v_counter + 1;
last_name_tab(v_counter) :=
name_rec.last_name;

Dbms_Output.Put_Line (
'last_name('||v_counter||'):
'||
last_name_tab(v_counter));
END LOOP;
END;
Declare
Cursor name_cur IS
Select last_name
From student
Where rownum <= 10;

Type last_name_type
Is Table Of
student.last_name%Type;
last_name_tab
last_name_type :=
last_name_type();
v_counter INTEGER := 0;
BEGIN
FOR name_rec IN name_cur
LOOP
v_counter := v_counter + 1;
last_name_tab.EXTEND;
last_name_tab(v_counter):=
name_rec.last_name;

Dbms_Output.Put_Line
('last_name('||v_counter||'):
'||
last_name_tab(v_counter));
END LOOP;
END;