Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

Is it possible to define package procedure/function outside of package body block (for Oracle)?

Simplified syntax for defining package body is:

create or replace package body <package_name> IS

  function <function_name>
   <function_body>

  procedure <procedure_name>
   <procedure_body>

end <package_name>;
/

Is it possible to define procedure within package like:

procedure <package_name>.<procedure_name>
 <procedure_body>

I ask this question as I am newbie and don't understand why I need to compile whole package when I need only to apply changes form a single procedure...

RELATED

Tom says:

  • Always use a package.
  • Never use a standalone procedure except for demos, tests and standalone utilities (that call nothing and are called by nothing)
share|improve this question
add comment

2 Answers

up vote 3 down vote accepted

You always need to compile the entire package body -- it is one item of code. You can create functions and procedures inside other procedures, but that does not change the need to recompile the package body.

What problem are you trying to solve here?

share|improve this answer
    
Thanks for answer.+1 As I say in question I am in situation when I have to apply fix to procedure from package. For newbie it is unclear that I must apply whole package in order to integrate small bug fix to part of package.... –  gavenkoa May 24 '13 at 10:09
1  
Yes, that's the case I'm afraid. Just recompile the package body though, not the package, unless the interface with any of the procedures or functions has changed. The package body is separated from the package so that recompilation of the body does not cause invalidation of other objects. –  David Aldridge May 24 '13 at 10:12
    
Thanks again! I had another question about recompilation of package header vs body and you answered it in comment!! –  gavenkoa May 24 '13 at 10:58
1  
Ah, well remember that when you're deploying code the best approach is to deploy all of the packages and then deploy the package bodies. You won't have to think about which order to deploy the individual packages in. –  David Aldridge May 24 '13 at 11:01
add comment

Not there. But your idea is a good one....

In Ada, which was the origin of PL/SQL, you could define a part of a package body, like a procedure, as "separate".

This would allow you to break up overly long package bodies (in Ada) without losing the internal variables etc.

Definitely would love to see it in PL/SQL.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.