Skip to Main Content
  • Questions
  • PLS-00306: wrong number of types of arguments in call to user defined type

Breadcrumb

Question and Answer

Chris Saxon

Thanks for the question, Ioana.

Asked: February 07, 2022 - 8:10 am UTC

Last updated: February 07, 2022 - 5:27 pm UTC

Version: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0

Viewed 10K+ times! This question is

You Asked

Hello,

I have a procedure which receive 2 parameters:

my_proc(param1 NUMBER, param2 my_table_type);


where my_table_type is table of my_type;

and my_type is record of (p1 number, p2 varchar2, p3 date, p4 number);

all of them are stored in a package.

when I execute:

declare
my_proc(111, my_table_type(123, 'aaa', to_date('02-FEB-2022','DD-MON-YY'), 444));
end;


I receive the error ORA-06550 PLS-00306: wrong number of types of arguments in call to my_table_type

Can you please help me with a hint?

Thank you!

and Chris said...

There are a couple of issues here:

- my_table_type is an array of my_type. Each argument to my_table_type must be of type my_type, e.g.:

my_table_type ( my_type ( 123, 'aaa', to_date('02-FEB-2022','DD-MON-YY'), 444) )


- You're on 11g, but array/type constructor syntax is only available from 18c onwards. So you'll need to do something like:

declare
  type my_type is record (
    p1 number, p2 varchar2(100), p3 date, p4 number
  );
  type my_table_type is
    table of my_type;
  
  rec my_type;
  arr my_table_type;

begin

  rec.p1 := 123;
  arr := my_table_type ();
  arr.extend;
  arr ( 1 ) := rec;

  p ( arr );
end;
/


Is this answer out of date? If it is, please let us know via a Comment

More to Explore

PL/SQL demos

Check out more PL/SQL tutorials on our LiveSQL tool.

PL/SQL docs

PL/SQL reference manual from the Oracle documentation library