?
Solved

how do i get the hostname in sql?

Posted on 2009-04-21
4
Medium Priority
?
3,254 Views
Last Modified: 2012-08-14
i've created a view on a db2 v9.1 on AIX
i need to extract the hostname in a variable, and use that variable in a query instead of hardcoding the hostname
how do i get the hostname (actual machine name) in sql?
select col1, 'MY_HARDCODED_HOST_NAME' as hostName, col2, etc

Open in new window

0
Comment
Question by:iamari
4 Comments
 
LVL 9

Expert Comment

by:rfportilla
ID: 24199145
0
 
LVL 27

Expert Comment

by:tliotta
ID: 24200640
The netnerds article is perhaps only partially correct. Apparently, what it's a solution for is the 'database name' rather than the hostname. Although those names are often the same, they're also often different. (The SQL0114 at the end of the article seems to reach the goal.)

So, please clarify _exactly_ what name is being sought.

A hostname would be useful for DNS resolution to an IP address. A database name would be useful for remote SQL requests.

Tom
0
 
LVL 37

Accepted Solution

by:
momi_sabag earned 500 total points
ID: 24201651
you can get it from a view called ENV_SYS_INFO  :
select HOST_NAME    
from SYSIBMADM.ENV_SYS_INFO
0
 
LVL 2

Author Closing Comment

by:iamari
ID: 31573018
thanks a lot, momi!
0

Featured Post

Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

November 2009 Recently, a question came up in the DB2 forum regarding the date format in DB2 UDB for AS/400.  Apparently in UDB LUW (Linux/Unix/Windows), the date format is a system-wide setting, and is not controlled at the session level.  I'm n…
Recursive SQL in UDB/LUW (you can use 'recursive' and 'SQL' in the same sentence) A growing number of database queries lend themselves to recursive solutions.  It's not always easy to spot when recursion is called for, especially for people una…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question