Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: Calling C programs from stored procs/functions
DMK42 wrote:
>
> Is it possible to invoke a C program from PL/SQL? In particular I'd like
> to call a C program from a stored proc. or function (V 7.1, soon to
> upgrade to 7.3), If possible I'd like to pass parameters to the program
> and get data back from it.
>
> If the program can't be called directly perhaps PL/SQL can invoke an OS
> command (AIX in my case) and run the program from the OS command line. Is
> this approach possible?
>
> I haven't been able to find anything on this in the Oracle documentaion or
> 3rd party PL/SQL texts.
>
> Any help would be greatly appreciated.
>
> Don Kaskowitz
> Oracle DBA
> kaskow_at_vitek.com
Try creating a Pro*C daemon that looks for requests to run specific programs (passing data to this Pro*C daemon can be done in a number of ways, DBMS_PIPE, DBMS_ALERT, UTL_FILE, or plain old table). The Pro*C daemon can do a fork() and exec() and spawn your required program/executable. Getting data back can be a little more difficult. Write return parameters to files or using plain return codes to the calling parent process (being your new Pro*C daemon). If these calling programs are Pro*C programs then you can use DBMS_PIPE, or pop the result in a table.
Note : Make sure you disconnect from the database before doing the fork()/exec(). Because fork and exec freaks out your oracle shadow process.
Note : Another difficulty may be in getting your PL/SQL program to wait for the C program to run, try using DBMS_ALERT.
Cheer
Justin Received on Tue Feb 04 1997 - 00:00:00 CST