Home » SQL & PL/SQL » SQL & PL/SQL » Re: module overloading
Re: module overloading [message #39366] Thu, 11 July 2002 14:19 Go to next message
Todd Barry
Messages: 4819
Registered: August 2001
Senior Member
1. No.

2. Yes, but this can be dangerous. By "body of a package", there are two possibilities - a variable global to the package body, and a local variable in a procedure.

If you declare a body "global" (in addition to declaring a spec variable of the same name), you can compile until you refer to that variable in a proc/function. Then you will hit an error (PLS-00371: at most one declaration for 'VARIABLENAME' is permitted in the declaration section).

If you declare a local variable, any unqualified reference within the proc/function will be to that local variable. If you qualify the variable name with the package name (pkg_name.variable_name), the reference will obviously be to the variable defined in the spec.

In any case, the duplicate names will make the code significantly harder to follow.
Re: module overloading [message #39380 is a reply to message #39366] Fri, 12 July 2002 10:43 Go to previous messageGo to next message
Radha Manohar
Messages: 3
Registered: July 2002
Junior Member
Thanks Todd for the reply. But the thing is I am able to create the following 2 standalone procedures successfully and also execute them successfully.
Whenever I execute, the most recently compiled one gets executed.

create or replace procedure numproc(a number,b out number)
is
begin
if a > 0 then
b := power(a,2);
else
dbms_output.put_line('a is negative');
end if;
end;
/

create or replace procedure numproc(a number,b out number)
is
begin
if a > 100 then
b := a / 2;
else
b := 0;
end if;
end;
/

Can you tell me what could be the reason?

Thanx in advance
Re: module overloading [message #39382 is a reply to message #39366] Fri, 12 July 2002 11:07 Go to previous message
Todd Barry
Messages: 4819
Registered: August 2001
Senior Member
Well, you said it yourself: "The most recently compiled one gets executed." Both versions of your procedure are NOT existing simultaneously - only the most recently compiled exists at any single point in time.

By the way, you wouldn't be able to overload those procedures in a package anyway because the parameter list and datatypes match exactly. The only way to overload is when they are different.
Previous Topic: External application call
Next Topic: ASP - Oracle Cursor not ready for I-O
Goto Forum:
  


Current Time: Thu Oct 17 05:29:03 CDT 2019