I have a package with two variables that has constant values like below.
person_name CONSTANT VARCHAR2 (15) := 'Adam';
person_city CONSTANT VARCHAR2 (15) := 'Houston';
This package variables are used across my database in stored procedures, other packages etc.
Now i want these variables to have values based on the client server who is calling. And i have all these maintained in a table like below
Server Parameter Value
Server1 person_name Adam
Server1 person_city Houston
Server2 person_name Victor
Server2 person_city Dallas
So when the package/SP is referenced/called from server1, i want my person_name and person_city to be defaulted to Adam and Houston.
Similarly when the package/SP is referenced/called from server2, i want my person_name and person_city to be Victor and Dallas.
How can this be done? Is there anyway in oracle side, the client who is calling a particular SP or using a package variable? I wrote a function to get the value like below.
in package,
person_name CONSTANT VARCHAR2 (15) :=GETPARAMVALUE(person_name);
person_city CONSTANT VARCHAR2 (15) :=GETPARAMVALUE(person_city);
and in the function, i will query the table
select * from parameterstable where parameter = (function's input) and servername = ????
How will i know the servername here?
Any help/tips will be appreciated. Thanks
Assuming that
server1andserver2are the client machines that are connecting to your server,should return the name of the client machine. You can use that in your
GetParamValuefunction to determine which row in the configuration table to read.