Parameter to Oracle Package

Hi,

I have an oracle package with a constant value at the top of PKB file as below

create or replace
PACKAGE BODY GEOHELPER AS

g_SRID pls_integer := 4326;

Open in new window


For some customers I want to user 4326 and for some 5638. What is the best method to change this from a .bat file? I do not want to have two versions of my package. Any ideas?
jim_imtechAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

sdstuberCommented:
If you put it in a bat file, you'll have generate the code yourself.

perhaps have a file with the bulk of the package body and then in your bat file

write out

create or replace
PACKAGE BODY GEOHELPER AS

g_SRID pls_integer :=

Open in new window


then apply whatever logic you need to determine 4326 vs 5638 and write that with semicolon

then append the rest of the body from the file
0
sdstuberCommented:
alternatively  put a BEGIN/END block within the package body itself that will set the value for you by some logic.
0
jim_imtechAuthor Commented:
I found this solution

ALTER SESSION SET plsql_ccflags='variable_name:1';
Then, in the package body, using the conditional compilation IF statement:

create or replace
PACKAGE BODY GEOHELPER AS

$IF $$variable_name = 1
$THEN
  g_SRID pls_integer := 4326;
$ELSIF $$variable_name = 2
$THEN
  g_SRID pls_integer := 5232;
$ELSE
  g_SRID pls_integer := 0;
$END
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
jim_imtechAuthor Commented:
I found this solution where the code change was only in setting the global variable
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Oracle Database

From novice to tech pro — start learning today.