use virtual table in PL/SQL block : Table of number « PL SQL « Oracle PL / SQL

Oracle PL / SQL
1. Aggregate Functions
2. Analytical Functions
3. Char Functions
4. Constraints
5. Conversion Functions
6. Cursor
7. Data Type
8. Date Timezone
9. Hierarchical Query
10. Index
11. Insert Delete Update
12. Large Objects
13. Numeric Math Functions
14. Object Oriented Database
15. PL SQL
16. Regular Expressions
17. Report Column Page
18. Result Set
19. Select Query
20. Sequence
21. SQL Plus
22. Stored Procedure Function
23. Subquery
24. System Packages
25. System Tables Views
26. Table
27. Table Joins
28. Trigger
29. User Previliege
30. View
31. XML
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Oracle PL / SQL » PL SQL » Table of number 
use virtual table in PL/SQL block
    
SQL>
SQL>
SQL> create or replace type virtual_table_type as table of number
  2      /

Type created.

SQL> create or replace
  2      function virtual_tablep_start number,
  3                              p_end number return virtual_table_type as
  4        l_vt_type virtual_table_type := virtual_table_type();
  5      begin
  6        for i in p_start .. p_end loop
  7          l_vt_type.extend();
  8          dbms_output.put_line'adding ' || i || ' to collection...' );
  9          l_vt_type(l_vt_type.count:= i;
 10       end loop;
 11       dbms_output.put_line'done...' );
 12       return l_vt_type;
 13     end virtual_table;
 14     /

Function created.

SQL> set serveroutput on
SQL>      begin
  2        for x in select *
  3                     from tablevirtual_table-22) ) )
  4        loop
  5          dbms_output.put_line'printing from anonymous block ' ||
  6                                x.column_value );
  7        end loop;
  8      end;
  9      /
adding -to collection...
adding -to collection...
adding to collection...
adding to collection...
adding to collection...
done...
printing from anonymous block -2
printing from anonymous block -1
printing from anonymous block 0
printing from anonymous block 1
printing from anonymous block 2

PL/SQL procedure successfully completed.

   
    
    
  
Related examples in the same category
1. TYPE NumbersTab IS TABLE OF NUMBER.
2. Legal and illegal table assignments.
3. Number Table by BINARY_INTEGER
4. Declare an index-by table variable to hold the employee records that we read in
5. Clear the salaries table by assigning the empty version to it
6. assignments to nested table elements, and the ORA-6533 error.
7. Use nested table constructors.
8. NULL key value in an index-by table
9. Try to insert elements 3 through 5
10. Use the Oracle10g Collection API COUNT method against an element.
11. Use the Oracle10g Collection API DELETE method against a set of elements.
12. Use the Oracle10g Collection API EXISTS method against an element.
13. Use the Oracle10g Collection API EXTEND method against an element.
14. Use the Oracle10g Collection API FIRST and LAST methods against a collection.
15. A nested table of a scalar variable:
16. Associate array: varchar2 to number map
17. Delete a elements from 2, 3 and 4.
18. Delete element 2.
19. number_list.EXTEND(2): Add two null value members at the end of the list.
20. number_list.EXTEND(3,4): Add three members at the end of the list and copy the contents of item 4
21. EXISTS method
22. Use variable.Last to get the last element
23. Extend space in number list.
24. FIRST method returns the lowest subscript value used in a collection
25. Table of number index by varchar2
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.