Tag Archives: find host

Oracle – Determining Local Host name and IP address with UTL_INADDR procedure

Oracle – Determining Local Host name and IP address with UTL_INADDR procedure

Oracle provides the procedure UTL_INADDR to retrieve your server’s host name and IP address from within the Oracle RDBMS. In this article we will demonstrate the retrieval of host name and IP address from within the RDBMS.

1. Logon to your Oracle database server as the Oracle software owner.

2. Logon to SQLPLUS with SYSDBA privileges.

mylinux:> sqlplus ‘/ as sysdba’

SQL*Plus: Release 10.2.0.4.0 – Production on Sat May 22 07:18:39 2010

Copyright (c) 1982, 2007, Oracle. All Rights Reserved.

Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 – 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL>

3. Execute the following PL/SQL block to retrieve the local hosts name and IP address.

SET serveroutput on
BEGIN
DBMS_OUTPUT.PUT_LINE(UTL_INADDR.GET_HOST_NAME); — get local host name
DBMS_OUTPUT.PUT_LINE(UTL_INADDR.GET_HOST_ADDRESS); — get local IP addr
END;
/

Output from SQL*PLUS

SQL> SET serveroutput on
SQL> BEGIN
2 DBMS_OUTPUT.PUT_LINE(UTL_INADDR.GET_HOST_NAME); — get local host name
3 DBMS_OUTPUT.PUT_LINE(UTL_INADDR.GET_HOST_ADDRESS); — get local IP addr
4 END;
5 /
mylinux
192.168.0.110

PL/SQL procedure successfully completed.

SQL>

This completes retrieval of local host name and IP address of your Oracle RDBMS server.

Larry J. Catt, OCP 9i, 10g
oracle@allcompute.com
www.allcompute.com