Showing posts with label ORA-06550. Show all posts
Showing posts with label ORA-06550. Show all posts

Wednesday, May 16, 2007

PLS-00307: too many declarations of XYZ match this call

While doing some tests before publishing my previous posting, i came across the following exception that is to be rarely seen when calling overloaded procedures (or functions) like this APEX_MAIL.SEND:

declare
var_addressee varchar2(255) := '...';
var_sender varchar2(255) := '...';
var_title varchar2(80);
begin
apex_mail.send(
p_to => var_addressee,
p_from => var_sender,
p_subj => var_title,
p_body => null);
end;

ORA-06550: line 6, column 1:
PLS-00307: too many declarations of 'SEND' match this call
ORA-06550: line 6, column 1: PL/SQL: Statement ignored

The problem is highlighted in purple.
Since APEX_MAIL.SEND comes in two versions (in other words it is an overloaded procedure), if we pass null to parameter p_body, the parser cannot decide whether it should reference the function version accepting p_body as VARCHAR2 or the version accepting p_body as CLOB.

The workaround is to replace null with some more meaningful expression.
Note that in general it could be enough to store null into a variable of the desired type, but this is not the case of APEX_MAIL.SEND that would just return the error i described in my previous posting.

Thursday, April 19, 2007

ORA-06550 and PLS-00201:identifier 'NVL2' must be declared

I must admit if was a bit surprised when i saw the following error this morning:

1 error has occurred
ORA-06550: line 4, column 3: PLS-00201: identifier 'NVL2' must be declared
ORA-06550: line 2, column 1: PL/SQL: Statement ignored

What's wrong with NVL2?!?!

Well, i tried using NVL2 as a PL/SQL expression rather than inside a SQL statement.

my_var := NVL2(old_value, new_value_if_not_null, new_value_if_null);

The fact is that there is a bunch of built-in functions like DECODE that have no counterpart in PL/SQL.
And Oracle documentation is a bit naive on this subject because it gives a list of built-in PL/SQL functions and says "refer to the SQL reference for a description of other functions", but it doesn't say "there is no NVL2 function", you must derive this rule looking up the desired function name in the list. Actually i found a paragraph where it mentions the absence of DECODE and others, but it doesn't mention NVL2.

In oracle SQL terms is if we had two tables containing the built-in functions accepted by SQL and built-ins accepted by PL/SQL, and we had to run a special query using set operators to find out what's missing.

select function_name
from sql_functions
minus
select function_name
from plsql_functions;

function_name
---------------
DECODE
DUMP
NVL2
...

Who knows why they forgot to include NVL2 in the PL/SQL built-ins.

yes you can!

Two great ways to help us out with a minimal effort. Click on the Google Plus +1 button above or...
We appreciate your support!

latest articles