How to Fix PLS-00306: Wrong Number or Types of Arguments in Call in Oracle

Match procedure and function calls to their parameter lists with USER_ARGUMENTS, and make calls clearer with named notation.

PLS-00306 is a compile error raised when a call to a procedure or function does not match any of its declared parameter lists: too many or too few arguments, a named parameter that does not exist, or an argument of a type that cannot be converted to the parameter's type. The message names the subprogram but not the mismatched argument, so compare the call with the parameter list in USER_ARGUMENTS.

Reproduce the Error

Example:

create or replace procedure demo_set_fare (p_route varchar2, p_fare number) is
begin
  dbms_output.put_line(p_route || ': ' || p_fare);
end;
/
begin
  demo_set_fare('DEL-BOM', 120, 'USD');          -- one argument too many
end;
/
begin
  demo_set_fare('DEL-BOM', sysdate);             -- a DATE where a NUMBER is expected
end;
/

Output:

Procedure DEMO_SET_FARE compiled

  demo_set_fare('DEL-BOM', 120, 'USD');          -- one argument too many
  *
ERROR at line 2:
ORA-06550: line 2, column 3:
PLS-00306: wrong number or types of arguments in call to 'DEMO_SET_FARE'
ORA-06550: line 2, column 3:
PL/SQL: Statement ignored

  demo_set_fare('DEL-BOM', sysdate);             -- a DATE where a NUMBER is expected
  *
ERROR at line 2:
ORA-06550: line 2, column 3:
PLS-00306: wrong number or types of arguments in call to 'DEMO_SET_FARE'
ORA-06550: line 2, column 3:
PL/SQL: Statement ignored

The first call passes three arguments to a procedure with two parameters; the second passes a DATE where a NUMBER is expected, and PL/SQL does not convert a DATE to a NUMBER.

Fix: Match the Parameter List

Example:

-- the parameters the procedure really has
select argument_name, position, data_type
from   user_arguments
where  object_name = 'DEMO_SET_FARE'
order  by position;
set serveroutput on
begin
  demo_set_fare(p_route => 'DEL-BOM', p_fare => 120);   -- named notation
end;
/

Output:

ARGUMENT_NAME       POSITION DATA_TYPE
________________ ___________ ____________
P_ROUTE                    1 VARCHAR2
P_FARE                     2 NUMBER

DEL-BOM: 120

PL/SQL procedure successfully completed.

USER_ARGUMENTS shows each parameter's name, position, and type. Named notation, p_fare => 120, makes the call clear and keeps working if parameters are reordered.

Other Common Causes

  • A required parameter, one without a DEFAULT, was left out.
  • A value is passed to an OUT or IN OUT parameter; it needs a variable.
  • A record or collection of a different type is passed, even if its fields are the same.
  • For overloaded subprograms, no version matches the argument types.
  • The procedure was changed in the database, and the calling code still uses the old parameter list.

Related Guides

Conclusion

PLS-00306 means the call does not fit the subprogram's parameters. Check the list in USER_ARGUMENTS, fix the number and types of arguments, pass variables to OUT parameters, and prefer named notation.

Vinish Kapoor
Vinish Kapoor

An Oracle ACE, author of four books on Oracle APEX, SQL and PL/SQL, and Oracle Forms, and a software developer building Oracle database applications since 2001.

guest

0 Comments
Oldest
Newest Most Voted