Print Friendly, PDF & Email

 
REQUEST

I want to get a value of the specific environment variable by querying a database.

 
SOLUTION

First, define a variable

oracle@dbpilot.net: export MYVAR="My Variable"
oracle@dbpilot.net: echo $MYVAR
My Variable

A value of any variable can be retrieved through DBMS_SYSTEM.GET_ENV procedure

COL OS_VAR FOR A30
VARIABLE OS_VAR VARCHAR2(50);
EXEC DBMS_SYSTEM.GET_ENV('MYVAR',:OS_VAR);

SQL> PRINT OS_VAR;

OS_VAR
------------------------------
My Variable

 
 

Version  : 14:53 19.01.2018
Database : Oracle database 10g – 12cR2