I decided to share my solution to this problem. To solve the problem, JavaB is used, so this solution will not work on Oracle XE. But this solution is cross-platform - it works on all operating systems with which I have come across. It also allows you to see the results of executing an external command in DBMS_OUTPUT.
Let's start the implementation: ')
Step 1: Create a Java based source.
Runtime rt = Runtime.getRuntime (); Process p = rt.exec (uFullCommand); BufferedReader in = new BufferedReader (new InputStreamReader (p.getInputStream ()));
String line = null; while ((line = in.readLine ())! = null) { System.out.println (line); } } };
Step 2: Wrap in PL / SQL.
CREATE OR REPLACE PROCEDURE host_command_proc (p_command IN VARCHAR2) AS LANGUAGE JAVA NAME 'Host.executeCommand (java.lang.String)'; /
Call example:
begin host_command_proc ("ls / tmp"); end;
And yes, the idea of this solution was borrowed from Tom Kite.