Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

PLS-00306: wrong number or type of argument in call to 'MULTISET_UNION_ALL'

943723Sep 7 2012 — edited Sep 7 2012
I'm trying to use MULTISET UNION to append several collections into a single recordset.

The select queries shown for the CURSOR are simple beta versions of the real queries which have about 350 fields to each of them. I will be appending data from 15 of these queries which each will with no more than 20 records per query into a new single recordset (not sure if 'recordset' is the correct phrase or term for what I mean, it could be ARRAY, OBJECT, COLLECTION or something else all together).

Here is text of the ERROR message:

ORA-06550: line 63, column 1:
PLS-00306: wrong number or type of argument in call to 'MULTISET_UNION_ALL'

ORA-06550: line 62, column 1:
PL/SQL: Statement ignored

ORA-06550: line 71, column 36:
PLS-00487: Invalid reference to variable 'VARCHAR2'

ORA-06550: line 71, column 5:
PL/SQL: Statement ignored

I think the error has to do with some defect in my declare statements.

I’m new to this so I’m sure there is a much more elegant and compact way to accomplish this.

DECLARE
  MyTID varchar2(10);


  CURSOR Cursor_rst1 IS
      SELECT d_owner_internal_id,
             d_internal_id,
             d_tid,
             d_entity_name,
             d_form_seq
        FROM rtns.itas_rtn_ct_1120_cor tblRecords
       WHERE d_form_seq = '2710' --Tax Year =2003
         AND D_TID = MyTID;
         
TYPE t_rst1 IS TABLE OF Cursor_rst1%ROWTYPE;
r_rst1 t_rst1;


  CURSOR Cursor_rst2 IS
      SELECT d_owner_internal_id,
             d_internal_id,
             d_tid,
             d_entity_name,
             d_form_seq
        FROM rtns.itas_rtn_ct_1120_cor tblRecords
       WHERE d_form_seq >= '11625' --Tax Year =2004
         AND D_TID = MyTID;      

TYPE t_rst2 IS TABLE OF Cursor_rst2%ROWTYPE;
r_rst2 t_rst2;


--***************************************************
-- I think the problem is here in these next few lines
--***************************************************

TYPE t_rst3 IS TABLE OF VARCHAR2(100);
r_rst3 t_rst3;
--r_rst3 t_rst3 := t_rst3 ();


BEGIN
  MyTID := '0000083';
    

    open Cursor_rst1;
         fetch Cursor_rst1 bulk collect into r_rst1;
    close Cursor_rst1;


    open Cursor_rst2;
         fetch Cursor_rst2 bulk collect into r_rst2;
    close Cursor_rst2;



--***************************************************
-- ERROR starts on this next line of code

-- This is the ERROR message produced:

-- ORA-06550: line 63, column 1:
-- PLS-00306: wrong number or type of argument in call to 'MULTISET_UNION_ALL'

-- ORA-06550: line 62, column 1:
-- PL/SQL: Statement ignored

-- ORA-06550: line 71, column 36:
-- PLS-00487: Invalid reference to variable 'VARCHAR2'

-- ORA-06550: line 71, column 5:
-- PL/SQL: Statement ignored
--***************************************************

r_rst3 := 
r_rst1 
MULTISET UNION 
r_rst2;
    
    
dbms_output.put_line('Results for r_rst3 shown below:');    

  FOR i IN r_rst3.first .. r_rst3.last LOOP
    dbms_output.put_line(r_rst3(i).d_owner_internal_id || ',  ' ||
                         r_rst3(i).d_internal_id || ',  ' ||
                         r_rst3(i).d_tid ||',  ' ||
                         r_rst3(i).d_entity_name || ',  ' ||
                         r_rst3(i).d_form_seq);
  END LOOP;

END;
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 5 2012
Added on Sep 7 2012
3 comments
2,067 views