Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: Get database name in OCI or PL/SQL
Jim,
As I said earlier, the end user most likely connect to their Oracle server
by
passing a TNS alias to my program. This alias defined in the tnsname.ora
file which encapsulates many configuration details, includeing the database
name in the SERVICE_NAME setting. For example, a customer may have
the following tnsname.ora entry:
XYZCorporateDatabase =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.1)(PORT = 1521))
)
(CONNECT_DATA = (SERVICE_NAME = ORCL816))
)
Then, my program only knows it is connected via XYZCorporateDatabase, but the OCIDescribeAny() function needs the database name ORCL816 as its parameter to create the OCI_PTYPE_DATABASE descriptor.
Why do I need this descriptor? Take a look at my original post below, and
no I do not want schema name. If you like to know what I am doing, take
a look at the two hyper-links I included in my original post and try to
write
an OCI program to get those database attributes. By doing so, you will
find out how poorly the OCI documentation was written for this feature,
and how clumzy the design is.
Thank you
--Michael
"Jim Kennedy" <kennedy-family_at_attbi.com> wrote in message
news:J4tm9.4006$dp1.9810_at_rwcrnsc52.ops.asp.att.net...
> Once you are connected I would think you already know the name. How did
you
> connect? Of what use is the database name anyway? It isn't like
SQLServer
> where you have multiple databases in an instance. Perhaps you mean the
> schema name? I've usedOracle for a long time and the only time I need the
> database name is either with regards to replication so we have unique
names
> or I am cloning a production system to a test system and I want to rename
> the database. (So I can have a test instance, a development instance on
the
> same machine all copies of a point in time of production.) OCIDescribeAny
> seems pretty straighforward maybe you wanted it too look more ODBC API
like?
> Jim
> >
> > >Received on Wed Oct 02 2002 - 09:46:18 CDT