How can i detect which version of Oracle is installed (by checking the registry)?


I need to check from a Visual Basic program the version of Oracle that is installed on the machine so i can choose between two different connection strings.

I think the Windows registry is the place to look for it and for Oracle8i i found in the key
the string value ORACLE_HOME_NAME which is "OraHome81"

and for Oracle10g i found in the key
the string value ORACLE_HOME_NAME which is "OraDb10g_home1"

However, as this application is installed on hundreds of server i want to be sure that checking those values is going to be enough for detecting the version of Oracle, i particularly feel unsure about the "OraDb10g_home1", can this differ depending on the installation and if so how can i know that indeed Oracle 10g is installed.


Who is Participating?
vs1784Connect With a Mentor Commented:
To retrieve the version information for Oracle, you execute the following SQL statement:

select * from v$version
where banner like 'Oracle%';

It should return something like this:

Oracle9i Enterprise Edition Release - 64bit Production
Guy Hengel [angelIII / a3]Billing EngineerCommented:
what would be the difference of the connection string?
what if both oracle8 and oracle 10 are installed?
johnsoneConnect With a Mentor Senior Oracle DBACommented:
I do not believe you can check the registry keys that way.  The "OraHome81" and "OraDb10g_home1" are values that are user input when the client is installed.  There are default values, but all you have to do is type over them.
Never miss a deadline with

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

JohannRamonAuthor Commented:

For Oracle 8i the connection string is:
sStringCnxion = "Provider=OraOLEDB.Oracle;Data Source=cn;User Id=/;Password="
And for oracle 10g the connection string is:
sStringCnxion = "Provider=OraOLEDB.Oracle;Data Source=cn;User Id=/;Password==;VCharNull=0" '

I need the "VCharNull=0" for Oracle 10g because of an issue that is detailed in this other question:
Of course i already tried using the same connection string for 8i but have problems.

If both Oracle 8i and Oracle 10g are installed then i will use Oracle 10g.


JohannRamonAuthor Commented:

Yep, but i need to set the connection string before connecting to the database...

I considered connecting, retreiving the version, disconnecting and then connecting again with the right connection string but it is not optimal and performance can be an issue.

Guy Hengel [angelIII / a3]Connect With a Mentor Billing EngineerCommented:
you could connect once when starting up the application, and do the check only once...
should not really a performance issue?!

JohannRamonAuthor Commented:

That is exactly what i'm worried about. I need to be sure about the version that is installed, it must be hidden somewhere!

johnsoneConnect With a Mentor Senior Oracle DBACommented:
The problem is if there is more than one version installed.  How would you know that there is more than one version, and if there is how would you switch between them?  Simply changing the connect string will not do that.

I think the safest way is to connect and then if you are connected to 10, disconnect and reconnect with the additional parameters.  If there is any type of hit, it is one time.
the performance difference will be marginal at best!
JohannRamonAuthor Commented:
Thanks all:

I really wanted to avoid the "pre-connection" way to solve this, especially because my VB program is a COM DLL and the first function that is called can change from one execution to another. There are other implications but that would be subject of another question.

I guess i should not be that stubborn and follow the approach of connecting first, disconnecting and reconnecting.

Working on the proof of concept, i will post again soon.

JohannRamonAuthor Commented:
Thanks again:

It was kind of difficult to split the points though ;) I tried to do my best and be fair.

Best regards,

All Courses

From novice to tech pro — start learning today.