Home » SQL & PL/SQL » SQL & PL/SQL » Use of DEFAULT in parameter list for spec and body
Use of DEFAULT in parameter list for spec and body [message #191284] Tue, 05 September 2006 08:18 Go to next message
SaraC
Messages: 81
Registered: August 2005
Member
Hi
I was under the impression that parameter lists in spec and body had to match exactly however I have come across some code that uses a DEFAULT clause in the procedure declaration in the package spec but it is not included in the declaration in the package body.

This must be valid as the code compiles. Just wondering how this can happen as havent seen it before.

Thanks
S
Re: Use of DEFAULT in parameter list for spec and body [message #191358 is a reply to message #191284] Tue, 05 September 2006 21:23 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
>Just wondering how this can happen as havent seen it before.
What other coding techniques have you not seen?
Have you ever saw overloaded parameters?
Re: Use of DEFAULT in parameter list for spec and body [message #191386 is a reply to message #191358] Wed, 06 September 2006 01:52 Go to previous messageGo to next message
Frank
Messages: 7901
Registered: March 2000
Senior Member
This has nothing to do with overloading. With overloading too, you have to code in your body (at least) what you declare in your spec.
Actually, this is a bug in Oracle, you can find several notes on it on Metalink.
SCOTT@xe>create or replace package faq
  2  as
  3    procedure test1
  4    ( p_param1 in varchar2 := 'NOTHING'
  5    );
  6  end faq;
  7  /

Package created.

SCOTT@xe>create or replace package body faq
  2  as
  3    procedure test1
  4    ( p_param1 in varchar2
  5    ) is
  6    begin
  7      dbms_output.put_line('p_param1 is '||p_param1);
  8    end test1;
  9  end faq;
 10  /

Package body created.

SCOTT@xe>exec faq.test1;
p_param1 is NOTHING

PL/SQL procedure successfully completed.
Re: Use of DEFAULT in parameter list for spec and body [message #191401 is a reply to message #191284] Wed, 06 September 2006 03:07 Go to previous messageGo to next message
SaraC
Messages: 81
Registered: August 2005
Member
anacedent - I have heard of overloading and know also the use of DEFAULT. I had just not seen DEFAULT being stated in spec declaration but missed out in the body declaration and still compiling correctly. I thought they had to be identical.

Thanks for clearing that up Frank.
Re: Use of DEFAULT in parameter list for spec and body [message #191402 is a reply to message #191386] Wed, 06 September 2006 03:09 Go to previous message
JSI2001
Messages: 1016
Registered: March 2005
Location: Scotland
Senior Member
Quote:

this is a bug in Oracle

I believe Oracle prefer to call it "An un-documented feature"
Laughing
Previous Topic: trigger : problem in old.columnvalue(urgent)
Next Topic: .net with stored procedure
Goto Forum:
  


Current Time: Tue Dec 03 12:55:31 CST 2024