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!

How to force initialization package to always be executed?

user3292382Nov 11 2014 — edited Nov 13 2014

Hello,

our goal is to call a procedure in a package every time any procedure/function in the same package is invoked.

That procedure checks something, and if it returns "true", it can execute the code of the procedure/function.

I try to better explain myself.

Let's create this Package Body:

CREATE OR REPLACE PACKAGE BODY test as

procedure set_format is

begin

  execute immediate 'alter session set NLS_territory=ITALY';

  execute immediate 'ALTER SESSION SET NLS_DATE_FORMAT=''dd-mm-yyyy''';

end;

function get_number return float is

begin

  return(123);

end;

END test;

If I call, via PL/SQL, the "get_number" function, I receive as expected the value "123":

SELECT test.get_number from dual

I want to add a function to this package, which is called every time I call the "get_number" function or any other procedure or function contained in the package.

I tried:

1) initialization: unfortunately it's executed only once, when the package is called the first time

2) PRAGMA SERIALLY_REUSABLE: unfortunately, i can't call any function or procedure via PL/SQL

So... I'm stuck.

Any ideas?

Thank you in advance.

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 11 2014
Added on Nov 11 2014
7 comments
2,408 views