473,395 Members | 1,443 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Where Am I ?

We have several identically defined databases that support a common set
of programs. Any program can run against any database. Is there a
function or a SYSIBM table that can provide the database name or,
alternately, provide the PLAN or PACKAGE name? This would be useful for
testing and possibly for logic.

Thanks,

Walter Rue
Nov 12 '05 #1
9 2059
WalterR wrote:
We have several identically defined databases that support a common set
of programs. Any program can run against any database. Is there a
function or a SYSIBM table that can provide the database name or,
alternately, provide the PLAN or PACKAGE name? This would be useful for
testing and possibly for logic.

Thanks,

Walter Rue

select db_name
from table(snapshot_database(cast(NULL as varchar(1)),
-1)
) as f;
DB_NAME
----------
TEST

Cheers
Serge

--
Serge Rielau
DB2 SQL Compiler Development
IBM Toronto Lab
Nov 12 '05 #2
WalterR wrote:
We have several identically defined databases that support a common set
of programs. Any program can run against any database. Is there a
function or a SYSIBM table that can provide the database name or,
alternately, provide the PLAN or PACKAGE name? This would be useful for
testing and possibly for logic.

Thanks,

Walter Rue

Or perhaps simpler - VALUES CURRENT SERVER - which returns alias you are
connected to.

If you want to use in SELECT - then SELECT CURRENT SERVER FROM SYSIBM.SYSDUMMY1
would do as well.

Jan M. Nelken
Nov 12 '05 #3
Walter, you mean z/OS or LUW ?

database name is slightly different concept for both systems.

and is it correct: you don't know exactly which database your
application is connecting to and which package it is using ?

Well, for packages: there are the system tables
SYSIBM.SYSPACKAGES
SYSIBM.SYSPACKLIST
having a relation to SYSIBM.SYSPLAN

complete list:
http://publib.boulder.ibm.com/infoce...jnrmstr571.htm

Not sure this is what you are looking for.

Nov 12 '05 #4
"juliane26" <ju*******@yahoo.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
Walter, you mean z/OS or LUW ?

Good question, since DB2 for z/OS has plans and packages, and DB2 for Linux,
UNIX, and Windows has only packages.
Nov 12 '05 #5
Jan:

I had already found this -- and tried it. But, since all of the (four)
databases run on the same server, it is not distinctive.

So far, I'm going to try Serge's suggestion and also look into the
SYSPLAN join opportunity.

Thanks,

Walter Rue
Jan M. Nelken wrote:
WalterR wrote:
We have several identically defined databases that support a common
set of programs. Any program can run against any database. Is there
a function or a SYSIBM table that can provide the database name or,
alternately, provide the PLAN or PACKAGE name? This would be useful
for testing and possibly for logic.

Thanks,

Walter Rue


Or perhaps simpler - VALUES CURRENT SERVER - which returns alias you are
connected to.

If you want to use in SELECT - then SELECT CURRENT SERVER FROM
SYSIBM.SYSDUMMY1 would do as well.

Jan M. Nelken

Nov 12 '05 #6
WalterR wrote:
I had already found this -- and tried it. But, since all of the (four)
databases run on the same server, it is not distinctive.


You are incorrect - here is a simple example from my machine which conveniently
has also 4 databases:

D:\Working>db2 list db directory

System Database Directory

Number of entries in the directory = 4

Database 1 entry:

Database alias = TBC_MD
Database name = TBC_MD
Database drive = D:\DB2
....
Database 2 entry:

Database alias = DWCTBC
Database name = DWCTBC
Database drive = D:\DB2
....

Database 3 entry:

Database alias = DWCTRLDB
Database name = DWCTRLDB
Database drive = D:\DB2
....

Database 4 entry:

Database alias = SAMPLE
Database name = SAMPLE
Database drive = D:\DB2

D:\Working>db2 connect to sample

Database Connection Information

Database server = DB2/NT 8.2.3
SQL authorization ID = DB2ADMIN
Local database alias = SAMPLE
D:\Working>db2 values current server

1
------------------
SAMPLE

1 record(s) selected.

D:\Working>db2 connect to dwctrldb

Database Connection Information

Database server = DB2/NT 8.2.3
SQL authorization ID = DB2ADMIN
Local database alias = DWCTRLDB
D:\Working>db2 values current server

1
------------------
DWCTRLDB

1 record(s) selected.

As you can see - it is quite distinctive. CURRENT SERVER special register
returns name of the application server (database) to which application is
connected.

See online documentation available at:

http://publib.boulder.ibm.com/infoce...help/index.jsp

Jan M. Nelken
Nov 12 '05 #7
WalterR wrote:
Jan:

I had already found this -- and tried it. But, since all of the (four)
databases run on the same server, it is not distinctive.


It is "distinctive" because CURRENT SERVER does not contain the name of the
(physical or virtual) machine on which things reside, but rather the name
of the database itself. Now, the issue is if you have multiple instances,
then each instance can have a database with a name that is the same as a
database in another instance. So you need the instance name as well to
uniquely identify a database. (That's all on LUW - I don't know about
iSeries or z/OS.)

--
Knut Stolze
DB2 Information Integration Development
IBM Germany
Nov 12 '05 #8
Knut:

I'm on z/OS, and our WIntel PCs use DB2-connect. But your explanation
of native LUW is interesting.

Thanks,

Walter Rue

Knut Stolze wrote:
WalterR wrote:

Jan:

I had already found this -- and tried it. But, since all of the (four)
databases run on the same server, it is not distinctive.

It is "distinctive" because CURRENT SERVER does not contain the name of the
(physical or virtual) machine on which things reside, but rather the name
of the database itself. Now, the issue is if you have multiple instances,
then each instance can have a database with a name that is the same as a
database in another instance. So you need the instance name as well to
uniquely identify a database. (That's all on LUW - I don't know about
iSeries or z/OS.)

Nov 12 '05 #9
Serge:

I pasted this into z/OS QMF and got nothing, so I must be too new at
this. Is "table" meant to be the name of a real DB2 table (the result
can vary by table?)? What is "snapshot_database" -- something in SYSIBM?

Pardon my ignorance, but please explain.

Thanks,

Walter Rue

Serge Rielau wrote:
WalterR wrote:
We have several identically defined databases that support a common
set of programs. Any program can run against any database. Is there
a function or a SYSIBM table that can provide the database name or,
alternately, provide the PLAN or PACKAGE name? This would be useful
for testing and possibly for logic.

Thanks,

Walter Rue


select db_name
from table(snapshot_database(cast(NULL as varchar(1)),
-1)
) as f;
DB_NAME
----------
TEST

Cheers
Serge

Nov 12 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

47
by: Andrey Tatarinov | last post by:
Hi. It would be great to be able to reverse usage/definition parts in haskell-way with "where" keyword. Since Python 3 would miss lambda, that would be extremly useful for creating readable...
3
by: A.V.C. | last post by:
Hello, I found members of this group very helpful for my last queries. Have one problem with CASE. I can use the column name alias in Order By Clause but unable to use it in WHERE CLAUSE. PLS...
3
by: Xiangliang Meng | last post by:
Hi, all. In 1998, I graduated from Computer Science Dept. in a university in China. Since then, I've been using C Language for almost 6 years. Although I'm using C++ in my current job, I'm also...
7
by: Britney | last post by:
Original code: this.oleDbSelectCommand1.CommandText = "SELECT TOP 100 user_id, password, nick_name, sex, age, has_picture, city, state, " + "country FROM dbo.users WHERE (has_picture = ?) AND (sex...
5
by: comp.lang.php | last post by:
if ($willLimitByDB) $sql = preg_replace('/#(+)#/i', '$$1', $sql); This does not give me the results I want, instead of the value of $where in $sql, I literally get '$where' instead. How do I...
5
by: John | last post by:
I just cannot manage to perform a SELECT query with NULL parameter... My CATEGORY table does have one row where TCATEGORYPARENTID is null (real DB null value). TCATEGORYID and TCATEGORYPARENTID...
0
NeoPa
by: NeoPa | last post by:
Background Whenever code is used there must be a way to differentiate the actual code (which should be interpreted directly) with literal strings which should be interpreted as data. Numbers don't...
1
by: not_a_commie | last post by:
I was hoping for increased functionality with the where clause in C# 3.0. Using the new keyword 'var' would really allow us to take nice advantage of these. Specifically: 1. I want to limit it...
9
by: Emin | last post by:
Dear Experts, I have a fairly simple query in which adding a where clause slows things down by at least a factor of 100. The following is the slow version of the query ...
8
by: chrisdavis | last post by:
I'm trying to filter by query or put those values in a distinct query in a where clause in some sort of list that it goes through but NOT at the same time. Example: ROW1 ROW2 ROW3 ROW4 ,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.