Re: Get database name in OCI or Transact-SQL

From: David Fitzjarrell <oratune_at_msn.com>
Date: 1 Oct 2002 11:19:44 -0700
Message-ID: <32d39fb1.0210011019.5a572f84_at_posting.google.com>


[Quoted] Comments embedded.

"Jim Kennedy" <kennedy-family_at_attbi.com> wrote in message news:<uH6m9.469950$kp.1327430_at_rwcrnsc52.ops.asp.att.net>...
> I don't know how using Transact SQL would work with an Oracle database.
> Transact-sql is a MS SQLServer thing.
> You could get the information from a v$table in the database. Look in the
> Oracle Reference guide.
> Jim

[Quoted] Try either:

select name from v$database;

or:

select instance_name from v$instance;

or:

select value from v$parameter where name = 'db_name';

Any of these should return the value you require.

David Fitzjarrell

> "Michael Chen" <michaelc7_at_earthlink.net> wrote in message
> news:Q61m9.1053$OB5.100694_at_newsread2.prod.itd.earthlink.net...
> > Hello,
> >
> > In Oracle 8i, function OCIDescribeAny can return OCI_PTYPE_DATABASE type
> > information such as OCI_ATTR_CURSOR_COMMIT_BEHAVIOR and
> > OCI_ATTR_LIST_SCHEMAS. To get the handle from OCIDescribeAny for a
> > database, you need to pass the database name:
> >
> >
> >
> http://download-west.oracle.com/otndoc/oracle9i/901_doc/appdev.901/a89857/oc
> > i15r32.htm
> > also
> >
> >
> http://download-west.oracle.com/otndoc/oracle9i/901_doc/appdev.901/a89857/oc
> > i06des.htm#444119
> >
> > The problem is my OCI connection may not have prior knowledge of the
> > database name. What is passed to function OCIServerAttach may be just the
> > TNS alias name defined in tnsnames.ora. Is there any way in OCI or
> > Transact-SQL for me to get the database name after the connection is
> > established?
> >
> > Thank for your help.
> >
> > --Michael
> >
> >
Received on Tue Oct 01 2002 - 20:19:44 CEST

Original text of this message