?
Solved

Value of %ORACLE_HOME%

Posted on 2003-10-30
9
Medium Priority
?
2,462 Views
Last Modified: 2007-12-19
Can someone tell me how to get the value of %ORACLE_HOME% or its equivalent from within a PL/SQL procedure.

0
Comment
Question by:SDutta
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
9 Comments
 
LVL 23

Expert Comment

by:seazodiac
ID: 9652742
Not trying to make this complicated, but the only way I would do is to use a java stored procedure since ORACLE_HOME is really an environment variable varying from platform to platform.

but I can tell you are using windows since you use % sign.

Here is an attempt from me:

In Oracle database sqlplus (of course you have to have JAVA enabled in the database)


---1.first create a java class in oracle database
SQL>create or replace and compile java source named "EnvLister"
AS
import java.io.*;
import java.util.Properties;

public class EnvLister extends Object
{

    public static void list_env()
   {
        Properties envLists = new Properties();
        String env_name = "ORACLE_HOME";
        try {
          envLists.load(  
               // use "/bin/env" on Unix
                Runtime.getRuntime().exec("C:\>set").getInputStream());
        } catch (Throwable t) {t.printStackTrace();}

        System.out.println("\n\n" + env_name
                         + " = " + envLists.get(env_name) );
    }
}

/

----create a PL./SQL procedure to wrap around java class
SQL> create or replace procedure env_list_proc  
          AS language java name 'EnvLister.list_env()';
         /

---Test it out

SQL>exec env_list_proc;


this should give your value of ORACLE_HOME.

I have not tested my code yet, but just give you an idea.
0
 
LVL 10

Author Comment

by:SDutta
ID: 9653524

Well, I guess that can be used to get the environment variable if it exists. What if the evironment variable is not set. Subsequent to release 8i the setting of ORACLE_HOME in the environment has been deprecated. See metalink note http://metalink.oracle.com/metalink/plsql/ml2_documents.showDocument?p_id=70215.1&p_database_id=NOT

Is the only way left is to read the registry ? I was hoping to query some simple view in the database that gets loaded at runtime.

0
 
LVL 23

Expert Comment

by:seazodiac
ID: 9653598
Not true in Unix. you still have to set Oracle_HOME in UNIX. you have tested this out yourself.

I agreed with you in windows family.
0
Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

 
LVL 7

Expert Comment

by:grim_toaster
ID: 9658586
As the value isn't probably going to change (mind you, if you have a cluster with different install paths...) you could create a directory reference in Oracle and reference it:

CREATE DIRECTORY ORACLE_HOME AS 'd:\ORA9'; (or whatever it is...)

And then at any later date access it as a directory.  (for further details, check out the Oracles SQL Reference manual).  Or, you could access it through the user/all_directories, but I'm unsure how efficient that will be!
0
 
LVL 10

Accepted Solution

by:
SDutta earned 0 total points
ID: 9660636
OK I think I found something simple that works for me on all releases that I care for.
Just need to take the name of the dll out from the end.

select file_spec from DBA_LIBRARIES where library_name = 'DBMS_SUMADV_LIB';

Will withdraw the question. Thanks Seazodiac and Grim_toaster for your inputs.

0
 
LVL 23

Expert Comment

by:seazodiac
ID: 9660706
Interesting!!! what an attempt!
I thought you would have had to go out of your way to find "ORACLE_HOME" in the data dictionary.

0
 
LVL 2

Expert Comment

by:akramryk
ID: 21438503
A simple thing with  dbms_system.get_env n 10g


Declare
var_home     Varchar2(100);
var_sid     varchar2(100);
BEGIN
dbms_system.get_env('ORACLE_HOME',var_home);
dbms_output.put_line(var_home);

dbms_system.get_env('ORACLE_SID',var_sid);
dbms_output.put_line(var_sid);

end;
/
0

Featured Post

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Why doesn't the Oracle optimizer use my index? Querying too much data Most Oracle developers know that an index is useful when you can use it to restrict your result set to a small number of the total rows in a table. So, the obvious side…
Truncate is a DDL Command where as Delete is a DML Command. Both will delete data from table, but what is the difference between these below statements truncate table <table_name> ?? delete from <table_name> ?? The first command cannot be …
This video explains at a high level with the mandatory Oracle Memory processes are as well as touching on some of the more common optional ones.
This video shows how to configure and send email from and Oracle database using both UTL_SMTP and UTL_MAIL, as well as comparing UTL_SMTP to a manual SMTP conversation with a mail server.
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question