Question

Is it possible to determine where Oracle is installed using pure PL/SQL?

Use case: In order to call an external C library, I need to know its exact path (for the create library call). My DLL will reside in Oracle's BIN directory, but I can't hard-code the path of the DB installation in my scripts...

Was it helpful?

Solution

On Windows and Oracle 10g, this works:

SELECT  
substr(file_spec,1,instr(file_spec,'\',1,3)) 
FROM dba_libraries 
WHERE library_name='DBMS_SUMADV_LIB'

OTHER TIPS

DECLARE
 RetVal VARCHAR2(100);
BEGIN
  dbms_system.get_env('ORACLE_HOME', RetVal);
  dbms_output.put_line(RetVal);
END;

NOTE: It is likely you that you will not have permission to this package by default.

Starting from Oracle 12c, you can use the SYS_CONTEXT function: Oracle docs

SET SERVEROUTPUT ON
BEGIN
   DBMS_OUTPUT.PUT_LINE(SYS_CONTEXT('USERENV','ORACLE_HOME'));
END;
/

/u01/app/oracle/product/12.1.0.2/dbhome_1
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top