System configuration
The server configuration details that will enable the calling of external procedures from within Oracle are shown below. You might already have something have something similar from a previous installation, in which case you can skip this part.
You should ideally have a separate listener for external procedures. Ensure that the KEY and SID values in the tnsnames.ora file correlate to the KEY and SID values in the listener.ora file.
The following files reside in the $TNS_ADMIN directory (normally $ORACLE_HOME/network/admin) and should be amended to suit your environment.
File $TNS_ADMIN/listener.ora:
-
# SET ORACLE_HOME TO your CURRENT environment
-
SID_LIST_LISTENER =
-
(SID_LIST =
-
(SID_DESC =
-
(SID_NAME = PLSExtProc)
-
(ORACLE_HOME = /opt/oracle/product/10g)
-
(PROGRAM = extproc)
-
(ENVS="EXTPROC_DLLS=ANY")
-
)
-
)
-
-
# SET HOST = 0.0.0.0 TO compensate FOR a bug in 10.1.0.2 RELEASE OF the
-
# Oracle listener - normally SET it TO DNS host name
-
LISTENER =
-
(DESCRIPTION_LIST =
-
(DESCRIPTION =
-
(ADDRESS_LIST =
-
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC))
-
)
-
(ADDRESS_LIST =
-
(ADDRESS = (PROTOCOL = TCP)(HOST = 0.0.0.0)(PORT = 1521))
-
)
-
)
-
)
File $TNS_ADMIN/tnsnames.ora:
-
EXTPROC_CONNECTION_DATA =
-
(DESCRIPTION =
-
(ADDRESS_LIST =
-
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC))
-
)
-
(CONNECT_DATA =
-
(SID = PLSExtProc)
-
(PRESENTATION = RO)
-
)
-
)
-
-
# Instance descriptions as per this example
-
SID_NAME =
-
(DESCRIPTION =
-
(ADDRESS = (PROTOCOL = TCP)(HOST = oracle1)(PORT = 1521))
-
(CONNECT_DATA =
-
(SERVER = DEDICATED)
-
(SERVICE_NAME = sid_name)
-
)
-
)
Configuration for two instances
File $TNS_ADMIN/listener.ora:
-
# Listener configuration
-
# This example supports two Oracle instances on server HAPPY
-
LISTENER =
-
(DESCRIPTION_LIST =
-
(DESCRIPTION =
-
(ADDRESS_LIST =
-
(ADDRESS = (PROTOCOL = TCP)(HOST = happy)(PORT = 1524))
-
)
-
)
-
)
-
-
CALLOUT_LISTENER =
-
(ADDRESS_LIST =
-
(ADDRESS =
-
(PROTOCOL = IPC)
-
(KEY = EXTPROC0)
-
)
-
)
-
-
SID_LIST_LISTENER =
-
(SID_LIST =
-
(SID_DESC =
-
(SID_NAME = INSTANCE1)
-
)
-
(SID_DESC =
-
(SID_NAME = INSTANCE2)
-
)
-
)
-
-
SID_LIST_CALLOUT_LISTENER =
-
(SID_LIST =
-
(SID_DESC =
-
(SID_NAME = PLSExtProc)
-
(ORACLE_HOME = /app/oracle/product/9.2.0)
-
(PROGRAM = extproc)
-
(ENVS="EXTPROC_DLLS=ANY")
-
)
-
)
File $TNS_ADMIN/tnsnames.ora:
-
EXTPROC_CONNECTION_DATA.WORLD=
-
(DESCRIPTION=
-
(ADDRESS_LIST=
-
(ADDRESS= (PROTOCOL=IPC)(KEY=EXTPROC0))
-
)
-
(CONNECT_DATA=
-
(SID=PLSExtProc)
-
(PRESENTATION= RO)
-
)
-
)
-
-
INSTANCE1.WORLD =
-
(DESCRIPTION =
-
(ADDRESS_LIST =
-
(ADDRESS = (PROTOCOL = TCP)(HOST = happy)(PORT = 1524))
-
)
-
(CONNECT_DATA =
-
(SERVICE_NAME = INSTANCE1)
-
)
-
)
-
-
INSTANCE2.WORLD =
-
(DESCRIPTION =
-
(ADDRESS_LIST =
-
(ADDRESS = (PROTOCOL = TCP)(HOST = happy)(PORT = 1524))
-
)
-
(CONNECT_DATA =
-
(SERVICE_NAME = INSTANCE2)
-
)
-
)
File $TNS_ADMIN/sqlnet.ora:
You might not have a sqlnet.ora file. If you do, keep it simple and only have the following in it:
-
NAMES.DIRECTORY_PATH= (TNSNAMES,ONAMES,HOSTNAME)
or in Oracle release 9 onwards:
-
NAMES.DIRECTORY_PATH= (TNSNAMES, EZCONNECT)
Restart the Oracle listener
This will manifest the changes that you made in the listener.ora file:
-
$ su - oracle
-
$ lsnrctl stop
-
$ lsnrctl start
-
$ lsnrctl status
Restart the database (as a last resort)
Only do this when none of your tests have succeeded.
-
$ su - oracle
-
$ sqlplus / as sysdba
-
SQL> shutdown immediate
-
SQL> startup
Testing
You can test the installation of this from within SQLPLUS:
-
$ sqlplus /nolog
-
SQL> connect / as sysdba
-
SQL> set autoprint on
-
SQL> variable i number;
-
SQL> exec :i:=hostcmd('touch /tmp/test');
- which should return 0 if the command succeeded, and <> 0 on failure.
You can test for the file's existance from within SQLPLUS by shelling out (use 'host' instead of '!' when running SQLPLUS from a DOS command line):
-
SQL> ! ls /tmp/test
- which should return:
-
/tmp/test