If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > how do get database alias from snapshot functions

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-19-06, 08:44
subramanyamp subramanyamp is offline
Registered User
 
Join Date: Mar 2006
Posts: 13
Question how do get database alias from snapshot functions

Hi
I need to get the alias for a database.
I am using following query. But the query returns '-'.

My db2version is 8.2

select INPUT_DB_ALIAS from TABLE (snapshot_database(cast (NULL as varchar(8)) , -2 )) as database

any idea how to get the database alias

Thanks in advance

subbu
Reply With Quote
  #2 (permalink)  
Old 04-19-06, 09:05
JAYANTA_DATTA JAYANTA_DATTA is offline
Registered User
 
Join Date: Oct 2004
Location: DELHI INDIA
Posts: 336
Just run the command : db2 "list db directory"

It will tell you the name of the database as well as the corresponding Alias name.

Thanks,
Jayanta
New Delhi, India
Reply With Quote
  #3 (permalink)  
Old 04-19-06, 09:20
subramanyamp subramanyamp is offline
Registered User
 
Join Date: Mar 2006
Posts: 13
Thanks
any idea why the query is not returning the alias name.

"select INPUT_DB_ALIAS from TABLE (snapshot_database(cast (NULL as varchar(8)) , -2 )) as database"

I have my db2 on windows.
Reply With Quote
  #4 (permalink)  
Old 04-19-06, 09:38
renga7 renga7 is offline
Registered User
 
Join Date: Jun 2001
Posts: 20
Try "select INPUT_DB_ALIAS from TABLE (snapshot_database('', -2 )) as database"
__________________
Renga
Reply With Quote
  #5 (permalink)  
Old 04-20-06, 02:46
subramanyamp subramanyamp is offline
Registered User
 
Join Date: Mar 2006
Posts: 13
The query returns only database name and not alias name.
Reply With Quote
  #6 (permalink)  
Old 04-20-06, 03:00
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,196
My guess is that you are connected to a database locally and there is no alias such as would be used for a remote connection (the alias is the same as the database and a null value is being returned).

You could use:

select coalesce(INPUT_DB_ALIAS, DB_NAME) from TABLE (snapshot_database(cast (NULL as varchar(8)) , -2 )) as database

This would return the DB_NAME if INPUT_DB_ALIAS is null.
__________________
M. A. Feldman
IBM Certified DBA on DB2 for Linux, UNIX, and Windows
IBM Certified DBA on DB2 for z/OS and OS/390
Reply With Quote
  #7 (permalink)  
Old 04-20-06, 03:15
subramanyamp subramanyamp is offline
Registered User
 
Join Date: Mar 2006
Posts: 13
Hi

I am connected to remote database using CLP.The database is catalogued using the alias name.My application requires getting both alias name as well as database name.

List database directory returns only alias name for both alias name and database name.

eg I have a database X which is given an alias name Y. So if i have to connect to the database i need to catalog it using alias name.

So how do i get both alias name and database name using the query since the "list datase directory" from a remote host returns only alias name.

Thanks in advance
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On