Introduction
This article introduces a class which automatically constructs Oracle TNS service names defined on a local machine.
Background
I always wonder how to find out how many Oracle instances are defined programmatically. Using SQL*Plus, one has to type in the Oracle instance name. In some cases, because we may have a lot of databases, we often make mistakes. One day I decided to write something to automatically discover all the Oracle instances defined on the local machine. So here comes COSidHelper
class.
Using the code
This code is very easy to use, you add SidHelper.h and SidHelper.cpp into your project, then when you need to display Oracle TNS service names, simply construct an instance of this class like this:
COSidHelper osidHelper;
for( int nIndex =0; nIndex < osidHelper.m_strArray.GetSize(); nIndex++ )
{
}
For test purposes, I also put in a Display()
method there.
Points of interest
- Check directory existence. In older Oracle client installs, tnsnames.ora is under net80, in newer version, it is under network directory.
RegistryKey
operation.
- Parser for Oracle tnsnames.ora file structure.
History
I wrote this class long time ago for a software called PowerQuery). Today finally got time to share it with CodeProject community. You can use this class for free.