Use the Oracle10g Collection API EXISTS method against an element. : Table of number « PL SQL « Oracle PL / SQL






Use the Oracle10g Collection API EXISTS method against an element.

   
SQL>
SQL> SET ECHO ON
SQL> SET SERVEROUTPUT ON SIZE 1000000
SQL>
SQL> DECLARE
  2
  3    
  4    TYPE number_table IS TABLE OF INTEGER;
  5
  6    
  7    number_list NUMBER_TABLE;
  8
  9    
 10    PROCEDURE print_list
 11      (list_in NUMBER_TABLE) IS
 12
 13    BEGIN
 14
 15      
 16      FOR i IN list_in.FIRST..list_in.LAST LOOP
 17
 18        
 19        IF list_in.EXISTS(i) THEN
 20
 21          
 22          DBMS_OUTPUT.PUT_LINE('List :'||list_in(i));
 23
 24        END IF;
 25
 26      END LOOP;
 27
 28    END print_list;
 29
 30  BEGIN
 31
 32    
 33    IF NOT number_list.EXISTS(1) THEN
 34
 35      
 36      number_list := number_table(1,2,3,4,5);
 37
 38    END IF;
 39
 40    
 41    DBMS_OUTPUT.PUT_LINE('Nested table before a deletion');
 42
 43    
 44    print_list(number_list);
 45
 46    
 47    number_list.DELETE(2);
 48
 49    
 50    DBMS_OUTPUT.PUT_LINE(CHR(10)||'Nested table after a deletion');
 51
 52    
 53    print_list(number_list);
 54
 55  END;
 56  /
Nested table before a deletion
List :1
List :2
List :3
List :4
List :5

Nested table after a deletion
List :1
List :3
List :4
List :5

PL/SQL procedure successfully completed.

SQL>

   
    
    
  








Related examples in the same category

1.use virtual table in PL/SQL block
2.TYPE NumbersTab IS TABLE OF NUMBER.
3.Legal and illegal table assignments.
4.Number Table by BINARY_INTEGER
5.Declare an index-by table variable to hold the employee records that we read in
6.Clear the salaries table by assigning the empty version to it
7.assignments to nested table elements, and the ORA-6533 error.
8.Use nested table constructors.
9.NULL key value in an index-by table
10.Try to insert elements 3 through 5
11.Use the Oracle10g Collection API COUNT method against an element.
12.Use the Oracle10g Collection API DELETE method against a set of elements.
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