Translate

NESTED TABLE FUNCTIONS

How Nested Table Functions are used in COLLECTIONS?

Following are some NESTED Table Function which you will find useful while dealing with COLLECTION Operations.

Nested Table Function - TABLE

PL/SQL Function that returns Collections and can be called in the From clause of a Select Statement.

Nested Table Function – CARDINALITY
The nested table function CARDINALITY is used to count the number of elements in a nested table. This functionality differs from the COUNT collection method slightly. The COUNT method raises an exception if the nested table is not initialized (IS NULL), while the CARDINALITY function returns a NULL. If the nested table has been initialized, both the COUNT and the CARDINALITY functions return the number of elements in the nested table.

Syntax
>──────CARDINALITY(x)──────><

If nested table x is not initialized, then NULL is Returned, otherwise the number of elements in Nested Table x is Returned as a Binary Integer.
DECLARE
TYPE NESTED_TAB_TYPE IS TABLE OF NUMBER;

NT1 NESTED_TAB_TYPE:= NESTED_TAB_TYPE (100,200,300);
NT2 NESTED_TAB_TYPE; /* Atomically NULL*/
NT3 NESTED_TAB_TYPE:= NESTED_TAB_TYPE (10,20,30,40,50,60);

BEGIN
DBMS_OUTPUT.PUT_LINE ('Cardinality of NT1 is '||CARDINALITY(NT1));
DBMS_OUTPUT.PUT_LINE ('Cardinality of NT2 is '||CARDINALITY(NT2));
DBMS_OUTPUT.PUT_LINE ('Cardinality of NT3 is '||CARDINALITY(NT3));
END;

Cardinality of NT1 is 3
Cardinality of NT2 is
Cardinality of NT3 is 6

PL/SQL procedure successfully completed.


Nested Table Function - COLLECT
The Nested Table function COLLECT maps a column to a collection. It works together with the CAST function which we used in above Example. The COLLECT function is similar to the MULTISET function in that MULTISET maps a subquery, while COLLECT maps a column.

Syntax
>──COLLECT (x)──><

The COLLECT function maps column x to a Nested Table. Use COLLECT in conjunction with the CAST function to convert the nested table, created by COLLECT, into the nested table type specified by the CAST function.
We will see this with the Example in below section of CAST Function.
  
Nested Table Function – CAST
The function CAST converts a collection or built-in data type to another collection or built-in datatype. CAST can work together with the COLLECT function to create collections out of scalar columns or with the MULTISET function to create collections out of a subquery.
CAST returns NULL if the collection is atomically NULL (not initialized). The CAST function is available in SQL or within SQL statements in PL/SQL.

If CAST is used to convert a scalar column value to a collection, it will need to be used in conjunction with either COLLECT or MULTISET. If CAST is used to convert one nested table type to another or a VARRAY to a nested table, it can be used independently of the COLLECT and MULTISET functions.

Syntax
>──────CAST(x AS y)──────><

Collection or expression x is converted to type y. Also see the COLLECT and MULTISET functions.
CREATE TYPE EMAIL_LIST_TYPE AS TABLE OF VARCHAR2(100);
 
/*COLLECT operates on a Column*/
SELECT CAST(COLLECT(EMP_EMAIL) AS EMAIL_LIST_TYPE)
FROM EMPLOYEES;
 
/* Which is equivalent to*/
SELECT CAST (MULTISET (SELECT EMP_EMAIL FROM EMPLOYEES) AS EMAIL_LIST_TYPE)
FROM DUAL;


When converting a Varray to a Nested Table, you do not need the COLLECT or MULTISET functions.
Note: The PHONE_NUMBERS column is a Varray and we use CAST to convert it to a Nested Table Type

CREATE TYPE CONTACT_LIST_TYPE AS TABLE OF VARCHAR2(100);

SELECT CAST (PHONE_NUMBERS AS CONTACT_LIST_TYPE)

FROM EMPLOYEES;

Nested Table Function - IN and NOT IN
The nested table function IN is used to determine if one nested table, or its equivalent, is included in a list of nested tables. The negative version NOT IN is used to determine if one nested table does not appear in a list of nested tables. This function returns a Boolean value TRUE, FALSE or NULL.

Syntax
>──NESTED_TABLE IN (NESTED_TABLE_LIST) ──><

Where NESTED_TABLE_LIST is a comma delimited list of nested tables. The Nested Table on the left of the IN function, as well as all nested tables in the nested table list, must be of the same declared type or the compiler will raise an exception.

If either the Nested Table on the left of the IN function is NULL or one of the Nested Tables in the nested table list is null, then Oracle returns a NULL.

To Return TRUE, Oracle requires that the Nested Table on the left of the IN function or an equivalent nested table appear in the comma delimited list of nested tables on the right of the IN function. Notice in the list below that NT1 IN (NT2) evaluates to TRUE, because NT2 is equal to NT1. For nested tables to be equal, they must have the same cardinality and element values but not the necessarily the same order of element values. See the Nested Table Function = for more information.
DECLARE
   TYPE NESTED_TAB_TYPE IS TABLE OF NUMBER;
   NT1 NESTED_TAB_TYPE:= NESTED_TAB_TYPE (20,30,40,80);
   NT2 NESTED_TAB_TYPE:= NESTED_TAB_TYPE (40,20,80,30);
   NT3 NESTED_TAB_TYPE:= NESTED_TAB_TYPE (10,20,30,40);
   NT4 NESTED_TAB_TYPE:= NESTED_TAB_TYPE (10,20,30);
 
BEGIN
   IF NT1 IN (NT2) THEN
       DBMS_OUTPUT.PUT_LINE ('NT1 Records are present in NT2');
  END IF;
  IF NT1 IN (NT3, NT4) THEN
       DBMS_OUTPUT.PUT_LINE ('NT1 Records are present in NT3 and NT4');   
  END IF;
  IF NT1 IN (NT2, NT3, NT4) THEN
      DBMS_OUTPUT.PUT_LINE ('NT1 Records are present in NT2, NT3 and NT4');   
   END IF;
END;
 
NT1 Records are present in NT2
NT1 Records are present in NT2, NT3 and NT4

PL/SQL procedure successfully completed.
If the nested tables on both sides of the IN or NOT IN are not declared using the same named TYPE then the compiler raises an exception before the PL/SQL block is executed. Notice in the following example that the Nested Tables NT1 and ANT1 are declared using different Named Types. NT1 uses the NESTED_TAB_TYPE, while ANT1 uses the ANOTHER_NESTED_TYPE.
DECLARE
   TYPE NESTED_TAB_TYPE IS TABLE OF NUMBER;
   NT1 NESTED_TAB_TYPE:= NESTED_TAB_TYPE (20,30,40);
/*NT2 NESTED_TAB_TYPE:= NESTED_TAB_TYPE (30,40,20);*/
/*NT2 is used in the commented Part below for Testing*/

TYPE ANOTHER_NESTED_TYPE IS TABLE OF NUMBER;
ANT1 ANOTHER_NESTED_TYPE:= ANOTHER_NESTED_TYPE (20,30,40);
BEGIN

   IF NT1 IN (ANT1) THEN
      DBMS_OUTPUT.PUT_LINE('NT1 and ANT1 are Equal');
      DBMS_OUTPUT.PUT_LINE('They are of same Datatype');
      DBMS_OUTPUT.PUT_LINE('They have the same Cardinality');
      DBMS_OUTPUT.PUT_LINE('The elements are Equal');
   END IF;

/* EQUALITY Check Commented which you can check by commenting above IF- END IF
   IF NT1 IN (NT2) THEN
      DBMS_OUTPUT.PUT_LINE('NT1 and ANT1 are Equal');
      DBMS_OUTPUT.PUT_LINE('They are of same Datatype');
      DBMS_OUTPUT.PUT_LINE('They have the same Cardinality');
      DBMS_OUTPUT.PUT_LINE('The elements are Equal');
   END IF;
*/
END;

 
   IF NT1 IN (ANT1) THEN
      *
ERROR at line 11:
ORA-06550: line 11, column 7:
PLS-00383: type mismatch found at 'NT1' inside an IN or NOT IN clause
ORA-06550: line 11, column 4:
PL/SQL: Statement ignored


Nested Table Function - IS A SET
The nested table function IS A SET is used to determine if a nested table contains unique elements. The negative version IS NOT A SET is used to determine if a nested table contains duplicate elements. This function returns a Boolean value TRUE, FALSE or NULL.

Syntax
>────x─┬─IS─────┬─A SET──────><
       └─IS NOT─┘


If the nested table x is composed of unique elements or is empty, a Boolean TRUE is returned. If x is NULL, then a NULL is returned. If x contains duplicate elements, then a FALSE is returned. For the negative version IS NOT A SET, if x contains duplicate elements, then a TRUE is returned. If x is NULL then a NULL is returned. If x is composed of unique elements or is empty, then a FALSE is returned.
DECLARE
   TYPE NESTED_TAB_TYPE IS TABLE OF NUMBER;
   NT1  NESTED_TAB_TYPE:= NESTED_TAB_TYPE (20,20,30,20,30);
   NT2  NESTED_TAB_TYPE;  /* Automatically NULL*/
   NT3  NESTED_TAB_TYPE:= NESTED_TAB_TYPE ();  /*Empty*/
   NT4  NESTED_TAB_TYPE:= NESTED_TAB_TYPE (20,30,40,50);
   Answer BOOLEAN;
BEGIN
   Answer := NT1 IS A SET;
   IF Answer IS NULL THEN
      DBMS_OUTPUT.PUT_LINE('NT1: Answer IS NULL');
   ELSIF Answer THEN
      DBMS_OUTPUT.PUT_LINE('NT1: Answer IS TRUE');
   ELSE
      DBMS_OUTPUT.PUT_LINE('NT1: Answer IS FALSE');
   END IF;

   Answer := NT1 IS NOT A SET;
   IF Answer IS NULL THEN
      DBMS_OUTPUT.PUT_LINE('NT1: Answer IS NULL');
   ELSIF Answer THEN
      DBMS_OUTPUT.PUT_LINE('NT1: Answer IS TRUE');
   ELSE
      DBMS_OUTPUT.PUT_LINE('NT1: Answer IS FALSE');
   END IF;

   Answer := NT2 IS A SET;
   IF Answer IS NULL THEN
      DBMS_OUTPUT.PUT_LINE('NT2: Answer IS NULL');
   ELSIF Answer THEN
      DBMS_OUTPUT.PUT_LINE('Nt2: Answer IS TRUE');
   ELSE
      DBMS_OUTPUT.PUT_LINE('NT2: Answer IS FALSE');
   END IF;

   Answer := NT3 IS A SET;
   IF Answer IS NULL THEN
      DBMS_OUTPUT.PUT_LINE('NT3: Answer IS NULL');
   ELSIF Answer THEN
      DBMS_OUTPUT.PUT_LINE('NT3: Answer IS TRUE');
   ELSE
      DBMS_OUTPUT.PUT_LINE('NT3: Answer IS FALSE');
   END IF;

   Answer := NT4 IS A SET;
   IF Answer IS NULL THEN
      DBMS_OUTPUT.PUT_LINE('NT4: Answer IS NULL');
   ELSIF Answer THEN
      DBMS_OUTPUT.PUT_LINE('NT4: Answer IS TRUE');
   ELSE
      DBMS_OUTPUT.PUT_LINE('NT4: Answer IS FALSE');
   END IF;

END;
 
NT1: Answer IS FALSE
NT1: Answer IS TRUE
NT2: Answer IS NULL
NT3: Answer IS TRUE
NT4: Answer IS TRUE

PL/SQL procedure successfully completed.



Nested Table Function - IS EMPTY
The nested table function IS EMPTY is used to determine if a nested table is initialized, but contains no elements. The negative version, IS NOT EMPTY, is used to determine if a nested table contains one or more elements. This function returns a Boolean value TRUE, FALSE or NULL.

Syntax

>────x─┬─IS─────┬─EMPTY──────><
       └─IS NOT─┘

If the nested table x is initialized, but contains no elements, a Boolean TRUE is returned. If x is NULL, then a NULL is returned. If x contains one or more elements, then a FALSE is returned. For the negative version IS NOT EMPTY; if x contains one or more elements, then a TRUE is returned. If x is NULL then a NULL is returned. If x is initialized but contains no elements, then a FALSE is returned.
DECLARE
   TYPE   NESTED_TAB_TYPE IS TABLE OF NUMBER;
   NT1    NESTED_TAB_TYPE := NESTED_TAB_TYPE (20,20,30,20,30);
   NT2   NESTED_TAB_TYPE;  /*Automatically null*/
   NT3   NESTED_TAB_TYPE:= NESTED_TAB_TYPE ();  /*Empty */
   Answer BOOLEAN;
BEGIN
   Answer := NT1 IS NOT EMPTY;
   IF Answer IS NULL THEN
      DBMS_OUTPUT.PUT_LINE('NT1: Answer IS NULL');
   ELSIF answer THEN
      DBMS_OUTPUT.PUT_LINE('NT1: Answer IS TRUE');
   ELSE
      DBMS_OUTPUT.PUT_LINE('NT1: Answer IS FALSE');
   END IF;

Answer := NT2 IS NOT EMPTY;
   IF Answer IS NULL THEN
      DBMS_OUTPUT.PUT_LINE('NT2: Answer IS NULL');
   ELSIF answer THEN
      DBMS_OUTPUT.PUT_LINE('NT2: Answer IS TRUE');
   ELSE
      DBMS_OUTPUT.PUT_LINE('NT2: Answer IS FALSE');
   END IF;

   Answer := NT3 IS EMPTY;
   IF Answer IS NULL THEN
      DBMS_OUTPUT.PUT_LINE('NT3: Answer IS NULL');
   ELSIF answer THEN
      DBMS_OUTPUT.PUT_LINE('NT3: Answer IS TRUE');
   ELSE
      DBMS_OUTPUT.PUT_LINE('NT3: Answer IS FALSE');
   END IF;

END;

NT1: Answer IS TRUE
NT2: Answer IS NULL
NT3: Answer IS TRUE
PL/SQL procedure successfully completed.



Nested Table Function - MULTISET
MULTISET allows you to retrieve a set of data and convert it on-the-fly to a collection type. The simplest example is this:

The examples related to multiset operators require that two nested tables be created and loaded with data as follows:

First, make a copy of the Customers table called Customers_Demo. We will add the nested table columns to Customers_Demo.
CREATE TABLE Customers_Demo AS SELECT * FROM customers;

Next, create a table type called Cust_Address_Tab_Typ. This type will be used when creating the nested table columns.
CREATE TYPE Cust_Address_Tab_Typ AS TABLE OF Cust_Address_Typ;

Now, create two nested table columns in the Customers_Demo table:
ALTER TABLE Customers_Demo
ADD (Cust_Address_Ntab Cust_Address_Tab_Typ,
       Cust_Address2_Ntab Cust_Address_Tab_Typ)
    NESTED TABLE Cust_Address_Ntab STORE AS Cust_Address_Ntab_Store
    NESTED TABLE Cust_Address2_Ntab STORE AS Cust_Address2_Ntab_Store;

Finally, load data into the two new nested table columns using data from the Cust_Address column of the Customers table:
UPDATE CUSTOMERS_DEMO CD
  SET Cust_Address_Ntab =
    CAST(MULTISET(SELECT Cust_Address
                    FROM Customers C
                    WHERE C.Customer_id =
                          CD.customer_id) As Cust_Address_Tab_Typ);

UPDATE CUSTOMERS_DEMO CD
  SET Cust_Address2_Ntab =
    CAST(MULTISET(SELECT Cust_Address
                    FROM Customers C
                    WHERE C.Customer_id =
                          CD.Customer_id) As Cust_Address_Tab_Typ);


Nested Table Function - MULTISET EXCEPT
The nested table function MULTISET EXCEPT compares two nested tables, returning a nested table containing the elements in one whose elements are not in the other. This comparison is similar to the set operator MINUS.

Nested Table Function - MULTISET INTERSECT
The nested table function MULTISET INTERSECT compares two nested tables, returning a nested table containing the elements that are in both. This comparison is similar to the set operator INTERSECT.

Nested Table Function - MULTISET Union
The nested table function MULTISET UNION compares two nested tables, returning a nested table containing the combined elements from both input tables. This comparison is similar to the set operator UNION ALL or UNION.
DISTINCT Indicates that only the distinct non-duplicate elements in the input nested tables are set in the returned nested table.

Below is the Example showing usage each of them:
CREATE OR REPLACE PROCEDURE Multiset_Example AS
      TYPE NestedTableType IS TABLE OF VARCHAR2(10);
      MyTable1 NestedTableType;
      MyTable2 NestedTableType;
      MyTable3 NestedTableType;
      Count_var INTEGER;
    BEGIN
      MyTable1 := NestedTableType('F', 'G', 'S');
      MyTable2 := NestedTableType('G', 'S', 'R');
 
     MyTable3 := MyTable1 MULTISET UNION myTable2;
     DBMS_OUTPUT.PUT('UNION: ');
     FOR Count_var IN 1..MyTable3.COUNT LOOP
       DBMS_OUTPUT.PUT(MyTable3(Count_var) || ' ');
     END LOOP;
     DBMS_OUTPUT.PUT_LINE(' ');
 
     MyTable3 := MyTable1 MULTISET UNION DISTINCT MyTable2;
     DBMS_OUTPUT.PUT('UNION DISTINCT: ');
     FOR Count_var IN 1..MyTable3.COUNT LOOP
       DBMS_OUTPUT.PUT(MyTable3(Count_var) || ' ');
     END LOOP;
     DBMS_OUTPUT.PUT_LINE(' ');
 
     MyTable3 := MyTable1 MULTISET INTERSECT MyTable2;
     DBMS_OUTPUT.PUT('INTERSECT: ');
     FOR Count_var IN 1..MyTable3.COUNT LOOP
       DBMS_OUTPUT.PUT(MyTable3(Count_var) || ' ');
     END LOOP;
     DBMS_OUTPUT.PUT_LINE(' ');
 
     MyTable3 := MyTable1 MULTISET EXCEPT MyTable2;
     DBMS_OUTPUT.PUT_LINE('EXCEPT: ');
     FOR Count_var IN 1..MyTable3.COUNT LOOP
       DBMS_OUTPUT.PUT(MyTable3(Count_var) || ' ');
     END LOOP;
END Multiset_Example;
/
Procedure created.
SQL> EXEC MULTISET_EXAMPLE;
UNION: F G S G S R
UNION DISTINCT: F G S R
INTERSECT: G S
EXCEPT:
PL/SQL procedure successfully completed.


Nested Table Function - SET
The nested table function SET examines a nested table and returns a nested table containing only the unique elements.

Syntax
>──SET(x)──><


The distinct elements in nested table x are returned. Nested table x and the returned table must both be of the same type. If x is null, then the returned table is null. If table x has no elements (is empty) then the returned table will be empty as well.
DECLARE
   TYPE NESTED_TAB_TYPE IS TABLE OF NUMBER;
   NT1    NESTED_TAB_TYPE:= NESTED_TAB_TYPE (20,20,30,20,30,40,50,50,60);
   NT2   NESTED_TAB_TYPE;  /* Automatically NULL */
   NT3   NESTED_TAB_TYPE:= NESTED_TAB_TYPE ();  /*Empty */
   Answer NESTED_TAB_TYPE;
   Loop_Counter PLS_INTEGER;
BEGIN
   Answer := SET(NT1);
   IF Answer IS NULL THEN
      DBMS_OUTPUT.PUT_LINE('Answer IS NULL');
   ELSIF Answer IS EMPTY THEN
      DBMS_OUTPUT.PUT_LINE('Answer IS EMPTY');
   ELSE
      DBMS_OUTPUT.PUT_LINE('Answer has '||Answer.COUNT||' Elements. They are:');
      FOR loop_counter IN Answer.FIRST..Answer.LAST
      LOOP
         IF Loop_Counter <> 1 THEN
            DBMS_OUTPUT.PUT(',');
         END IF;
         DBMS_OUTPUT.PUT(Answer(Loop_Counter));
      END LOOP;
      DBMS_OUTPUT.NEW_LINE;
   END IF;
END;
/
Answer has 5 Elements. They are:
20,30,40,50,60

PL/SQL procedure successfully completed.


Nested Table Function - SUBMULTISET OF and NOT SUBMULTISET OF
The nested table functions SUBMULTISET OF and NOT SUBMULTISET OF compare two nested tables to determine if all elements in the first nested table also appear in second nested table. This function returns a Boolean value TRUE, FALSE or NULL. The key word OF is optional.

Syntax

>───x─┬─────┬─SUBMULTISET [OF] y──────><
      └─NOT─┘

If all of the elements in nested table x also appear in nested table y or nested table x is empty and y is NOT NULL, then a Boolean TRUE is returned. If either x or y is NULL (not initialized), then a NULL is returned. If x contains elements that do not appear in nested table y, then a FALSE is returned.

For the negative version NOT SUBMULTISET OF; if nested table x contains any elements that are not in nested table y, then a TRUE is returned. If either nested table x or y is NULL then a NULL is returned. If all elements in nested table x also appear in nested table y, then a FALSE is returned.
DECLARE
   TYPE  NESTED_TAB_TYPE IS TABLE OF NUMBER;
   NT1   NESTED_TAB_TYPE:= NESTED_TAB_TYPE(20,20,30,20,30);
   NT2   NESTED_TAB_TYPE;  /* Automatically Null */
   NT3   NESTED_TAB_TYPE:= NESTED_TAB_TYPE(20);
   Answer BOOLEAN;
BEGIN
   Answer := NT3 SUBMULTISET OF NT1;
   IF Answer IS NULL THEN
      DBMS_OUTPUT.PUT_LINE('Answer IS NULL');
   ELSIF answer THEN
      DBMS_OUTPUT.PUT_LINE('Answer IS TRUE');
   ELSE
      DBMS_OUTPUT.PUT_LINE('Answer IS FALSE');
   END IF;
END;

Answer IS TRUE

PL/SQL procedure successfully completed.


Nested Table Function - <>
The nested table function <> is used to compare two nested tables for inequality. This function returns a Boolean value TRUE, FALSE or NULL.
Syntax
 >──Nested_Table <> Nested_Table──><

Both nested tables must be of the same named type or the compiler will raise an exception.
If either nested table is atomically null (declared but not initialized), then Oracle returns a NULL. To return TRUE, Oracle requires at least one of the following conditions to be met: 
  •       The two nested tables must differ in cardinality (number of elements)
  •       The element values must differ from one nested table to the other.
DECLARE
   TYPE NESTED_TAB_TYPE IS TABLE OF NUMBER;
   NT1 NESTED_TAB_TYPE:= NESTED_TAB_TYPE(20,30,40);
   NT2 NESTED_TAB_TYPE:= NESTED_TAB_TYPE(40,20,30);
   NT3 NESTED_TAB_TYPE:= NESTED_TAB_TYPE(10,20,30,40);
   NT4 NESTED_TAB_TYPE:= NESTED_TAB_TYPE (10,20,30);
BEGIN
   IF (NT1 <> NT2) THEN
   DBMS_OUTPUT.PUT_LINE('NT1 and NT2 are not equal');
   DBMS_OUTPUT.PUT_LINE('They have different cardinality');
   DBMS_OUTPUT.PUT_LINE ('Or the elements are different');
   ELSE 
   DBMS_OUTPUT.PUT_LINE ('NT1 and NT2 are Equal');
   END IF;
   IF (NT1 <> NT3) THEN
   DBMS_OUTPUT.PUT_LINE('NT1 and NT3 are not equal');
   DBMS_OUTPUT.PUT_LINE('They have different cardinality');
   DBMS_OUTPUT.PUT_LINE('Or the elements are different');
   ELSE 
   DBMS_OUTPUT.PUT_LINE ('NT1 and NT3 are Equal');
   END IF;
   IF (NT1 <> NT4) THEN
   DBMS_OUTPUT.PUT_LINE('NT1 and NT4 are not equal');
   DBMS_OUTPUT.PUT_LINE('They have different cardinality');
   DBMS_OUTPUT.PUT_LINE('Or the elements are different');
   ELSE 
   DBMS_OUTPUT.PUT_LINE ('NT1 and NT4 are Equal');
   END IF;
END;

NT1 and NT2 are Equal
NT1 and NT3 are not equal
They have different cardinality
Or the elements are different
NT1 and NT4 are not equal
They have different cardinality
Or the elements are different

PL/SQL procedure successfully completed.
If the nested tables on both sides of the equal sign are not declared using the same named TYPE, then the compiler raises an exception before the PL/SQL block is executed. Notice in the following example that the nested tables nnt1 and ant1 are declared using different named types. nnt1 uses the NESTED_TAB_TYPE, while ant1 uses the  ANOTHER_NESTED_TAB_TYPE.
DECLARE
   TYPE NESTED_TAB_TYPE IS TABLE OF NUMBER;
   NT1 NESTED_TAB_TYPE:= NESTED_TAB_TYPE (20,30,40);
 
   TYPE ANOTHER_NESTED_TAB_TYPE IS TABLE OF NUMBER;
   ANT1 ANOTHER_NESTED_TAB_TYPE:= ANOTHER_NESTED_TAB_TYPE(20,30,40);
BEGIN
   IF (NT1 <> ANT1) THEN
      DBMS_OUTPUT.PUT_LINE ('NT1 and ANT1 are not equal');
      DBMS_OUTPUT.PUT_LINE ('They have the same cardinality');
      DBMS_OUTPUT.PUT_LINE ('The elements are equal');
   END IF;
END;

   IF (NT1 <> ANT1) THEN
           *
ERROR at line 8:
ORA-06550: line 8, column 12:
PLS-00306: wrong number or types of arguments in call to '!='
ORA-06550: line 8, column 4:
PL/SQL: Statement ignored




No comments:

Post a Comment