3 Replies Latest reply: Mar 29, 2012 8:29 AM by Billy~Verreynne RSS

    how can i compare two nested table..here is sample code..

    ShailendraNagina
      TYPE nestedTableType IS TABLE OF VARCHAR2(10);
      myTable1 nestedTableType;
      myTable2 nestedTableType;
      result BOOLEAN;
      BEGIN
      myTable1 := nestedTableType('A', 'F', 'G');
      myTable2 := nestedTableType('B', 'E', 'H');

      result := myTable1 = myTable2;
      IF result THEN
      ~~~~
      END IF;

      demo code
      It is showing error in ...
      result := myTable1 = myTable2;
      please help me...:)
        • 1. Re: how can i compare two nested table..here is sample code..
          jeneesh
          It is working for me.. Whats your version?
          BANNER
          
          Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Prod
          PL/SQL Release 10.2.0.4.0 - Production
          CORE     10.2.0.4.0     Production
          TNS for 32-bit Windows: Version 10.2.0.4.0 - Production
          NLSRTL Version 10.2.0.4.0 - Production
          
          
          
          SQL> declare
            2  TYPE nestedTableType IS TABLE OF VARCHAR2(10);
            3  myTable1 nestedTableType;
            4  myTable2 nestedTableType;
            5  result BOOLEAN;
            6  BEGIN
            7  myTable1 := nestedTableType('A', 'F', 'G');
          myTable2 := nestedTableType('B', 'E', 'H');
            8    9
           10  result := myTable1 = myTable2;
           11  IF result THEN
           12   dbms_output.put_line('Hi.......');
           13  else
           dbms_output.put_line('Ih.......');
           14   15  END IF;
           16  end;
           17  /
          Ih.......
          
          PL/SQL procedure successfully completed.
          • 2. Re: how can i compare two nested table..here is sample code..
            Peter vd Zwan
            Hi,

            It works for me too.
            BANNER                                                                         
            --------------------------------------------------------------------------------
            Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production     
            PL/SQL Release 11.2.0.1.0 - Production                                           
            CORE     11.2.0.1.0     Production                                                         
            TNS for 64-bit Windows: Version 11.2.0.1.0 - Production                          
            NLSRTL Version 11.2.0.1.0 - Production                                           
            Regards,

            Peter
            • 3. Re: how can i compare two nested table..here is sample code..
              Billy~Verreynne
              Shailendra Nagina wrote:
              TYPE nestedTableType IS TABLE OF VARCHAR2(10);
              Nested table is a horrible term to use and a complete misnomer. The structure is called an array or a collection in other languages. And is the appropriate term to use in PL/SQL too.

              Calling something a "+table+" in a RDBMS context mean a very specific type of SQL data structure with numerous features - like partitioning, hash or index storage structure, secondary indexes ranging from B+tree to bitmap, and a host of other features.

              And a "+nested table+" or "+PL/SQL table+" is NOTHING AT ALL like this.

              If you want to compare collections/arrays in PL/SQL, the multiset operator can be used. I've just posted an example of that in {message:id=10241831}.