Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Is there a PL/SQL compiler directive to include source from outside the source member being compiled

micheljchJan 23 2019 — edited Jan 25 2019

Is there by any possibility a compiler directive for Oracle PL/SQL to identify another source member whose contents would be fetched and replace the directive when the package or procedure is compiled? This would be similar to '#include' in C or what we used to refer to as macros in s/370 assembly language.  Out of necessity the source being included would only be stored as text and not compiled itself.  I'm thinking the answer must be no since this would seemingly require a source type other than PACKAGE, PACKAGE BODY, or PROCEDURE, but I'd rather know for sure rather than assume.

For example, given a source member named INCLUDED_CODE in the APPS schema that contains the following:

XX_MESSAGE   varchar(100)

XX_EXCEPTION exception;

procedure XX_ABORT (XX_MSG_CODE in number,XX_MSG_TEXT in varchar)

as

begin       

    XX_MESSAGE := substr('XX-'||to_char(abs(XX_MSG_CODE)||': '||XX_MSG_TEXT||chr(32)||chr(13)||chr(10)||SQLERRM,1,100);

    raise XX_EXCEPTION;                   

end;

/

And a package body:

create or replace package body APPS.XX_TEST_PKG

as

procedure XX_TEST_PROC (ERRBUFF out nocopy varchar2,RETCODE out nocopy varchar2,P_INPUT in varchar2)

is

   

$INCLUDE APPS.XX_ABORT

       

--

-- MAINLINE

--

begin

    . 

    .

    .

    XX_ABORT(-20001,'<some message text>'');

    .

    .

    .

exception

when XX_EXCEPTION

then

    ERRBUFF := XX_MESSAGE;

    RETCODE := 2;       

end XX_TEST_PROC;                                  

   

end XX_TEST_PKG;

/

The compiler would see the following upon execution of the member including the package body:

procedure XX_TEST_PROC (ERRBUFF out nocopy varchar2,RETCODE out nocopy varchar2,P_INPUT in varchar2)

is

   

XX_MESSAGE   varchar(100)

XX_EXCEPTION exception;

procedure XX_ABORT (XX_MSG_CODE in number,XX_MSG_TEXT in varchar)

as

begin       

    XX_MESSAGE := substr('XX-'||to_char(abs(XX_MSG_CODE)||': '||XX_MSG_TEXT||chr(32)||chr(13)||chr(10)||SQLERRM,1,100);

    raise XX_EXCEPTION;                   

end;

       

--

-- MAINLINE

--

begin

    . 

    .

    .

    XX_ABORT(-20001,'<some message text>'');

    .

    .

    .

exception

when XX_EXCEPTION

then

    ERRBUFF := XX_MESSAGE;

    RETCODE := 2;       

end XX_TEST_PROC;                                  

   

end XX_TEST_PKG;

Comments
Post Details
Added on Jan 23 2019
10 comments
792 views