1

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)

2 Answers 2

3

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?

4
  • 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, 2013 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. May 24, 2013 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, 2013 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. May 24, 2013 at 11:01
0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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