Re: Executing UNIX commands from Oracle

From: Thomas B Cox <Thomas.B.Cox_at_tek.com>
Date: 24 Feb 95 21:21:15 GMT
Message-ID: <Thomas.B.Cox.28.2F4E4DCB_at_tek.com>


>>[...] can i [...] have a stored procedure actually execute
>>operating system commands?
 

>You could not do this directly, as far as I know. The only thing I can think
>of is to use the ORACLE database pipe packaged procedures to set up
>a client-server type arrangement. I haven't got the manuals to hand but the
>concept is that :-
 

> 1) A server process (implemented in Pro*C for example) listens on a pipe
> 2) your stored procedure passes the script details down the pipe
> 3) the server uses the system() call to execute the script

Step 1 is not as easy as it looks. I recommend using the DBMS_ALERT package. (Otherwise you're running a resource-intensive loop of constantly trying to grab stuff out of the pipe even when it's empty, which may be most of the time.)

The program that's listening is actually registered for an alert. Then, at Step 2, your stored proc. passes the script info into the pipe, or into a table, depending, and then sends the alert. The alert wakes up the listening program, it grabs whatever out of the pipe (or table), makes the system() call, etc.

Cheers.

 -Tom Received on Fri Feb 24 1995 - 22:21:15 CET

Original text of this message