Question

I've searched a lot to find an answer if there is a way to include procedures, which are written in different files to package.

Folders can look like:

Packages
  |
  Package1
     |
     Procedures
         |
         proc1.sql
         proc2.sql
     package1.sql
...

in package1.sql I wish to have package head and body, but certain procedures should be stored in files proc1.sql etc.

Is there any way to do it?
It could realy help with large body package or with packages wchich have a lot of procedures.

Thank in advance :)

Was it helpful?

Solution

This isn't possible. A CREATE OR REPLACE PACKAGE or CREATE OR REPLACE PACKAGE BODY statement must be complete-- it has to contain the entire package specification or the entire package body. That means that the entire spec has to be in a single statement in a single file and the entire body has to be in a single statement in a single file. You can separate the header and the specification into different files, of course, but you can't separate either into multiple pieces unless you're using some preprocessing tool to reassemble the chunks before sending them to the database.

At the point where a package is large enough that a single file becomes unwieldy to work with and where there are multiple subcomponents that could be logically grouped together into a smaller unit, I would strongly suspect that the right answer is to refactor the package into multiple smaller, better focused packages. It's very much like an object-oriented programmer that finds that one of their classes has, over time, grown into a god object/ Winnebago object that does too much and really covers the ground that two or three objects should be responsible. It's best to bite the bullet and to start refactoring rather than trying to solve the problem by breaking up the source.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top