473,378 Members | 1,378 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

PLS-00307 - Function Overloading Problem

Hi all.

Here's my problem:

Consider a package MY_PKG with the following two functions

FUNCTION get_number_by_rowid(
p_table_name IN VARCHAR2,
p_column_name IN VARCHAR2,
p_rowid IN UROWID,
p_result OUT NUMBER
) RETURN PLS_INTEGER;

FUNCTION get_number_by_rowid(
p_table_name IN VARCHAR2,
p_column_name IN VARCHAR2,
p_rowid IN UROWID,
p_error_code IN PLS_INTEGER := -20001
) RETURN NUMBER;

Now here's a code block with an invocation of the function:

DECLARE
v_rc pls_integer;
v_table_name varchar2(30);
v_rowid UROWID;
v_result number;
BEGIN
v_table_name := '...';
v_rowid := '....';
v_rc := MY_PKG.get_number_by_rowid(
v_table_name, 'surrogat', v_rowid, v_result
);
....
END;

On our 10g-Server this compiles well, but a customer reports, that on compilation of the block above (not the package, which compiles well) he receives 'PLS-00307: Too many declarations of "get_number_by_rowid" match this call'. And I have to admit: THAT'S CORRECT! Which of the two prototypes is to be executed? In both cases, we have 4 Arguments with types VARCHAR2, VARCHAR2, UROWID for the first three in both signatures, while the forth one is OUT NUMBER resp. IN PLS_INTEGER. Since the 4th argument of the invocation is a variable (a L-Value for people knowing C/C++), it might be an IN as well as an OUT-argument (since each L-Value is a R-Value also), so that's no help either. I don't know excatly, whether PLS_INTEGER is a subtype of NUMBER, but by mere intuition they belong to the same data type "family" of numeric datatypes, so I have to agree with our customer's compiler (don't know the exact client and server versions yet), that the invocation is indeed ambiguos.

So - why does our 10g server, along with a 9i client, compile the invocation code without problems? How can it determine the correct function variant to use? Would using named notation for the 4th argument help to resolve to conflict (v_rc := MY_PKG.get_number_by_rowid(v_table_name, surrogat', v_rowid, p_result => v_result)?
Oct 4 '07 #1
3 4838
debasisdas
8,127 Expert 4TB
Yes PLS_INTEGER is a subtype of NUMBER.

Over loading can't be done only by changinmg the parameter mode.

To overload the signature ( either the paramter type or the number of parameter )must be different, not the mode.
Oct 4 '07 #2
OK, that's what I tried to outline, parameter mode cannot be a criterion - but how is it possible, that the invocation compiles and executes OK on hundreds of customer client/server combos (including our own), and only ONE is known to receive the error?

Yes PLS_INTEGER is a subtype of NUMBER.

Over loading can't be done only by changinmg the parameter mode.

To overload the signature ( either the paramter type or the number of parameter )must be different, not the mode.
Oct 4 '07 #3
Here's a short test block for everyone to check:

declare
n number;
procedure f1(p1 in varchar2, p2 in varchar2, p31 out number) is
begin
dbms_output.put_line('A f1(p1 in varchar2, p2 in varchar2, p31 out varchar2)');
end;
procedure f1(p1 in varchar2, p2 in varchar2, p32 in pls_integer := -20001) is
begin
dbms_output.put_line('B f1(p1 in varchar2, p2 in varchar2, p32 in pls_integer := -20001)');
end;
begin
f1('s', 's', n);
f1('s', 's', -20999);
end;
/

This block compiles and runs OK on my system! I receive this output (Server 10.2.0.1, Client 9.2.0.5):

A f1(p1 in varchar2, p2 in varchar2, p31 out varchar2)
B f1(p1 in varchar2, p2 in varchar2, p32 in pls_integer := -20001)

The "correct" functions are executed, though one would expect PLS-00307 to be thrown. It'd be nice if one of you could check how the block performs on his system.

Here's the version that should work on every system, becaus it uses named notation (mixed with positional notation) to identify the variant to be used:

declare
n number;
procedure f1(p1 in varchar2, p2 in varchar2, p31 out number) is
begin
dbms_output.put_line('A f1(p1 in varchar2, p2 in varchar2, p31 out varchar2)');
end;
procedure f1(p1 in varchar2, p2 in varchar2, p32 in pls_integer := -20001) is
begin
dbms_output.put_line('B f1(p1 in varchar2, p2 in varchar2, p32 in pls_integer := -20001)');
end;
begin
f1('s', 's', p31 => n);
f1('s', 's', p32 => -20999);
end;
/
Oct 4 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: windos | last post by:
Guys, I'm newbie here and tryin to create a simple procedure : ---- CREATE OR REPLACE PROCEDURE update_status IS CURSOR cekstat is select b.CREATOR_PROC_INST_ID, b.MANAGED_FILE_ID,...
1
by: manish | last post by:
Hi, I am a fresher in the programming field i.e although I have done programming at the basic level but at professional level I am very new and I am facing many problems. These probllems are...
6
by: ritagoldman101 | last post by:
Pls help - how to find Domain owner For most people this may be an easy question...but not for me. How can I find out who the owner of a domain is so I can write to her / him and ask if she /...
4
by: Zamolxe | last post by:
fter creating a Office prj in C# this error appears is the wordDoc is oppened, if the prj is compiled and runed from the IDE the WORD is opening and after a nanosec it closes. How can I fix this. ...
8
by: Raghu Raman | last post by:
Hi , i want to compile my asp.net app from the commandline window.could you please tell me how. With thanks Drop in the ocean.
2
by: Raghu Raman | last post by:
Hi , am storing the session id in my database when the user signs in.The session_on start is firing nice & am doing my DB operations there & quite working good. But when the user closes the...
0
by: sathyakvani | last post by:
hi al i wrote a code (LOgin form) that checks the user id and if it exists validates the password but this is not all validating and simply displaying user does not exist i am sending the code...
17
by: Riaaaa | last post by:
Pls check my code for the stored procedure which i created for the companydetails including companyid P.K. Not Null int(4), companyname Not Null varchar (20), address varchar(30) where...
1
by: vbsoft | last post by:
Hello My Name is Mike Am from Nigeria a student of computer Science, Pls i want your You to help in Using VISUAL BASIC 6.0 AND MS SQL SERVER AS DATABASE AS A CLIENT SERVER SIDE pLS: I...
0
by: sonuindia88 | last post by:
Some common confusions .I am reading Ritchie and Deitel and practising questions from Yashwant Kanetkar...Here are some of the confusions i am having..your help is required.... Q1) ...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.