Selecting Database Name

From TekiWiki
Revision as of 06:44, 27 May 2016 by WikiSysop (Talk | contribs)

Jump to: navigation, search

To select the Oracle Database name, the most common method is:

SELECT name FROM v$database

This, however, requires special permissions. The database name is part of the session context and can be selected using the following function:

SELECT sys_context('USERENV', 'DB_NAME') FROM dual

When used as part of a larger query, this does not need to join the v$database pseudo table.

This is particularly useful in packaged solutions like PeopleSoft.

For more hints and tips like this, see the eBook:

UsingFunctionsInPeopleSoftQuerySmall.jpg

Using Functions in PeopleSoft Query

PeopleSoft Query