How to get OS environment variables in PL/SQL

If you need to find out the value of any OS environment variable, such as ORACLE_HOME, without connecting your remote server. You can use DBMS_SYSTEM.GET_ENV procedure as shown below.

DECLARE

    V_ENVIROMENT VARCHAR2(500);

BEGIN

    SYS.DBMS_SYSTEM.GET_ENV('ORACLE_HOME', V_ENVIROMENT);

    DBMS_OUTPUT.PUT_LINE(V_ENVIROMENT);

END;

However, I don’t recommend using it in application code. It is instance specific. So, it can be misleading in RAC environment. In addition, it is undocumented. There is no guarantee that it will be in future versions.

Leave a Reply

Your email address will not be published. Required fields are marked *