Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can you get the name of the DB you are currently connected to in SQL?

Status
Not open for further replies.

Fooch

Programmer
Dec 19, 2005
63
0
0
US
I have a program with a lot of SQL connections in it and although I know how to open, close, use, change, etc. I can't find a way to pull the DB name I am currently connected to. I have a service program with a log procedure in it that does SQL connects. What I want to do is when the "logger" is called I want to check the current SQL connection, then reset it, do my logging and change the connection back to what it was before leaving the logger. Is there a was in embedded SQL to get the DataBase name that I am connected to?
 
On AS/400 the database name is IBM DB/2 UDB. Do you mean the table names on which your SQL Statements operates?
 
Or did you mean the library?

There is a command PRTSQLINF, which prints some SQL info.
 
Is there a was in embedded SQL to get the DataBase name that I am connected to?
Code:
d CurrentServer       s         18a   Varying
 /free
  exec sql Set :CurrentServer = CURRENT SERVER;
 
Using STRSQL:

Code:
SELECT current server FROM sysibm/sysdummy1

returns the server name (i.e., the machine).

Nullum gratuitum prandium.
--Sleipinir214

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top