Nested tables | Varrays | Index-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; |
SQL, SQL Server, Tutorials, Oracle, PL/SQL, Interview Questions & Answers, Joins, Multiple Choice Questions, Quiz, Stored Procedures, Select, Insert, Update, Delete and other latest topics on SQL, SQL Server and Oracle.
PL/SQL Tables
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment