Decreasing the Size of an Array : Varray « Collections « Oracle PL/SQL Tutorial

Oracle PL/SQL Tutorial
1. Introduction
2. Query Select
3. Set
4. Insert Update Delete
5. Sequences
6. Table
7. Table Joins
8. View
9. Index
10. SQL Data Types
11. Character String Functions
12. Aggregate Functions
13. Date Timestamp Functions
14. Numerical Math Functions
15. Conversion Functions
16. Analytical Functions
17. Miscellaneous Functions
18. Regular Expressions Functions
19. Statistical Functions
20. Linear Regression Functions
21. PL SQL Data Types
22. PL SQL Statements
23. PL SQL Operators
24. PL SQL Programming
25. Cursor
26. Collections
27. Function Procedure Packages
28. Trigger
29. SQL PLUS Session Environment
30. System Tables Data Dictionary
31. System Packages
32. Object Oriented
33. XML
34. Large Objects
35. Transaction
36. User Privilege
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
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 Tutorial » Collections » Varray 
26. 2. 28. Decreasing the Size of an Array

You cannot delete an element inside the array.

Even if you set it to NULL, it still exists.

The only thing you can do is decrease the size of the array.

SQL>
SQL> declare
  2      type month_va is varray(13of VARCHAR2(20);
  3      v_month_va month_va:=month_va();
  4      v_count_nr number;
  5  begin
  6      v_month_va.extend(3);
  7      v_month_va(1):='January';
  8      v_month_va(2):='February';
  9      v_month_va(3):='March';
 10
 11      v_month_va(2):=null;
 12      if v_month_va.exists(2)
 13      then
 14         DBMS_OUTPUT.put_line('Object Exists');
 15      end if;
 16
 17      v_month_va(3):=v_month_va(2);
 18      v_month_va.trim(1);
 19      DBMS_OUTPUT.put_line('Count:'||v_month_va.count);
 20      DBMS_OUTPUT.put_line('Last:'||v_month_va.last);
 21  end;
 22  /
Object Exists
Count:2
Last:2

PL/SQL procedure successfully completed.

SQL>
SQL>
26. 2. Varray
26. 2. 1. Creating a Varray Type
26. 2. 2. Using VARRAYs
26. 2. 3. Getting Information on Varrays
26. 2. 4. VARRAY in action
26. 2. 5. Inside the loop, you are accessing array elements by their subscripts.
26. 2. 6. Assign value to VARRAY
26. 2. 7. Defining our type to be a VARRAY with 10 elements, where each element is a varying character string of up to 15 characters.
26. 2. 8. CREATE TABLE with a VARRAY
26. 2. 9. Loading a Table with a VARRAY in It: INSERT VALUEs with Constants
26. 2. 10. Query VARRAY column
26. 2. 11. Query table with VARRAY type column by column name
26. 2. 12. Manipulating the VARRAY with The TABLE Function
26. 2. 13. If aliases are used, they must be used consistently
26. 2. 14. Manipulating the VARRAY with The VARRAY Self-join
26. 2. 15. VARRAY of Cursor
26. 2. 16. The COUNT Function
26. 2. 17. LAST and COUNT give the same result for VARRAYs.
26. 2. 18. A procedure that uses EXISTS and LAST
26. 2. 19. EXISTS and LAST
26. 2. 20. Using PL/SQL to Create Functions to Access Elements
26. 2. 21. The CAST function converts an object type (such as a VARRAY) into a common type that can be queried. Oracle 10g automatically converts the VARRAY without the CAST.
26. 2. 22. One way to make the 'members' behave like an array is first to include the row number in the result set like this:
26. 2. 23. Then, the individual array element can be extracted with a WHERE filter:
26. 2. 24. Extracting individual members of a VARRAY may be accomplished using two other functions: THE and VALUE
26. 2. 25. Column_value is a built-in function/pseudo-variable that is held over from the DBMS_SQL package
26. 2. 26. Loop through by using the built-in NEXT, PRIOR.
26. 2. 27. The subscript of the last element is always equal to the size of the array.
26. 2. 28. Decreasing the Size of an Array
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.