I have a C library which should be called from a pl/sql function so I make a .so library and after that I create a pl/sql function to call it.
the C source(libcprog.c) is like this:
int exec_hmmftg ( char *p1 , char *p2, char *p3 ){}
the library in oracle database is:
CREATE LIBRARY CPROGLIB UNTRUSTED AS '/libcprog.so';
the created pl/sql function is:
CREATE OR REPLACE FUNCTION CALL_C_PROGRAM(P1 IN VARCHAR2,
P2 IN VARCHAR2,
P3 IN OUT VARCHAR2)
RETURN BINARY_INTEGER
IS EXTERNAL NAME "exec_hmmftg"
LIBRARY CPROGLIB
LANGUAGE C
PARAMETERS(P1 STRING, P2, P3 BY REFERENCE STRING, RETURN INT);
When I tried to call CALL_C_PROGRAM I catch:
ORA-01405: fetched column value is NULL
How can I know where is the problem?
New
I changed library definition to address somewhere wrong and I still catch the same exception!
Is there a parameter or something which I have to set before calling the function?
Best Answer
The following configuration works for me on Oracle 11.2.0.2:
C prog:
Compile it, and make sure it's placed in
$ORACLE_HOME/bin
or$ORACLE_HOME/lib
(configuration can be changed to allow other directories) - compiler flags will differ for AIX too.Configure
EXTPROC
in thelistener.ora
file:Restart the listener with
lsnrctl stop
followed bylsnrctl start
.Create the reference to the external library & create the function to interface between PL/SQL and the C prog:
Test the function:
Not quite sure what you're doing wrong without seeing the full C you've written. Try and setup this simple case I've made for you, then add functionality bit by bit from there.