Re: PL/SQL8 Call to C Shared libraries [message #370413] |
Wed, 22 September 1999 13:49 |
Mario
Messages: 10 Registered: September 1999
|
Junior Member |
|
|
Have you done all this (see example below)?
/* In the MyProg.c File Code the Following: */
#include <STDIO.H>
#include <STRING.H>
#include <CTYPE.H>
#include <STDLIB.H>
int TestFunc(int Arg1)
{
return Arg1*8;
} /* TestFunc */
/* At the UNIX Prompt, Compile and Link the Program to generate a
Shared library (On HP-UX B.11.00 A 9000/889) */
$ cc -c +DA2.0W -dynamic +DD32 MyProg.c
$ ld -b MyProg.o
$ mv a.out MyProg.so
/* In the /etc/tnsnames.ora File, Add the Following Entry: */
extproc_connection_data =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = TestKey))
(CONNECT_DATA = (SID = RETRDEV8))
)
/* In the /etc/listener.ora File, Add the Following Entries: */
EXTERNAL_PROCEDURE_LISTENER =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL=ipc)
(KEY=TestKey)
)
)
SID_LIST_EXTERNAL_PROCEDURE_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = RETRDEV8)
(ORACLE_HOME=/rdbms/v8.0.5-32)
(PROGRAM=extproc)
)
)
/* At the UNIX Prompt, start a Separated Listener Process. */
$ lsnrctl start EXTERNAL_PROCEDURE_LISTENER
$ sqlplus tsigsyp@retrdev8
Enter password: *********
Connected.
CREATE OR REPLACE LIBRARY TestLib AS '/home/dbagroup/spoulin/MyProg.so';
Operation 159 succeeded.
CREATE OR REPLACE FUNCTION TestFuncPLSQL (Arg1 IN BINARY_INTEGER)
RETURN BINARY_INTEGER AS
EXTERNAL LIBRARY TestLib
NAME "TestFunc"
LANGUAGE C
CALLING STANDARD C
PARAMETERS (Arg1 int, RETURN);
/
Function created.
VARIABLE TESTVAR NUMBER;
BEGIN
:TestVar := TestFuncPLSQL (10);
END;
/
PL/SQL procedure successfully completed.
SQL> print TestVar
TESTVAR
----------------
80
EXIT;
C.Q.F.D.
|
|
|