Link to home
Start Free TrialLog in
Avatar of iamari
iamari

asked on

how do i get the hostname in sql?

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

Avatar of rfportilla
rfportilla
Flag of United States of America image

Avatar of Member_2_276102
Member_2_276102

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
ASKER CERTIFIED SOLUTION
Avatar of momi_sabag
momi_sabag
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of iamari

ASKER

thanks a lot, momi!