Simpler Navigation for Servers and Operating Systems
Completed: a much simpler Servers and Operating Systems section of the Community. We combined many of the older boards, so you won't have to click through so many levels to get at the information you need. Check the consolidated boards here as many sub-forums are now single boards.
General
cancel
Showing results for 
Search instead for 
Did you mean: 

Getting a basic Oracle external C procedure to work

Stephen Andreassend
Regular Advisor

Getting a basic Oracle external C procedure to work

Platform is Oracle 9.2.0.5 64bit and HPUX 11 64bit.

Here is my C code:

cat call_rm.c

#include
char cmd[512];
void call_rm(char *fname)
{
strcpy(cmd,"/usr/bin/rm -f ");
strcat(cmd, fname);
system(cmd);
return;
}

I have placed this file in $ORACLE_HOME/lib.

I use GCC to compile it.

cd $ORACLE_HOME/lib
/usr/local/pa20_64/bin/gcc -c call_rm.c

The nextstep is to run make, but I cannot get it to work:

/usr/local/bin/gmake -f $ORACLE_HOME/rdbms/demo/demo_rdbms.mk extproc_callback SHARED_LIBNAME=call_rm.so OBJS=call_rm.o

cc +DA2.0W +DS2.0 -DSS_64BIT_SERVER -I/u01/app/oracle/product/9.2/rdbms/demo -I/u01/app/oracle/product/9.2/rdbms/public -I/u01/app/oracle/product/9.2/plsql/public -I/u01/app/oracle/product/9.2/network/public -c -I/u01/app/oracle/product/9.2/rdbms/demo -I/u01/app/oracle/product/9.2/rdbms/public -I/u01/app/oracle/product/9.2/plsql/public -I/u01/app/oracle/product/9.2/network/public -I/u01/app/oracle/product/9.2/precomp/public call_rm.c
(Bundled) cc: "call_rm.c", line 3: error 1705: Function prototypes are an ANSI feature.
gmake: *** [call_rm.o] Error 1


Obviously I need to edit $ORACLE_HOME/rdbms/lib/env_rdbms.mk and change the references from cc to gcc.

Do I also need to use gmake?
2 REPLIES
Stephen Andreassend
Regular Advisor

Re: Getting a basic Oracle external C procedure to work

No worries, found that I can achieve the same task using the PLSQL package:

dbms_backup_restore.deletefile();

Brilliant.
R. Allan Hicks
Trusted Contributor

Re: Getting a basic Oracle external C procedure to work

Just in case you should need a c function...

I don't know about gcc, but cc requires -Aa for ANSI mode, otherwise it defaults to K&R mode.
"Only he who attempts the absurd is capable of achieving the impossible