The EXISTS Table Attribute : Associative Arrays « Collections « Oracle PL/SQL Tutorial






SQL>
SQL> DECLARE
  2    Type t_FirstNameTable IS TABLE OF VARCHAR(20)
  3    INDEX BY BINARY_INTEGER;
  4    FirstNames  t_FirstNameTable;
  5  BEGIN
  6    -- Insert rows into the table.
  7    FirstNames(1) := 'Scott';
  8    FirstNames(3) := 'Joanne';
  9
 10    -- Check to see if rows exist.
 11    IF FirstNames.EXISTS(1) THEN
 12      DBMS_OUTPUT.put_line('Row 1 exists!');
 13    ELSE
 14      DBMS_OUTPUT.put_line('Row 1 doesn''t exist!');
 15    END IF;
 16    IF FirstNames.EXISTS(2) THEN
 17      DBMS_OUTPUT.put_line('Row 2 exists!');
 18    ELSE
 19      DBMS_OUTPUT.put_line('Row 2 doesn''t exist!');
 20    END IF;
 21  END;
 22  /
Row 1 exists!
Row 2 doesn't exist!

PL/SQL procedure successfully completed.

SQL>
SQL>








26.7.Associative Arrays
26.7.1.Associative Arrays demo
26.7.2.Associative arrays (index-by tables)
26.7.3.PL/SQL Table
26.7.4.Index by string
26.7.5.Nested Table with Table row elements inside
26.7.6.Assign value to PL/SQL table
26.7.7.TABLE.Exist
26.7.8.Clear the salaries table by assigning the empty version to it
26.7.9.Place some values into the salaries table
26.7.10.PL/SQL table of cursor
26.7.11.Select data into PL/SQL table of cursor
26.7.12.Use For loop to output data in a PL/SQL table of cursor
26.7.13.Use for all loop to loop through the PL/SQL table
26.7.14.Change PL/SQL table element by index
26.7.15.Insert data in PL/SQL table to a real table
26.7.16.The COUNT Table Attribute
26.7.17.Uses the COUNT method to display the number of rows contained in an index-by table
26.7.18.The DELETE Table Attribute
26.7.19.The EXISTS Table Attribute
26.7.20.FIRST and LAST Table Attributes
26.7.21.NEXT and PRIOR Table Attributes
26.7.22.Using INDEX BY BINARY_INTEGER
26.7.23.Indexing Associative Arrays