Forum Stats

  • 3,759,068 Users
  • 2,251,496 Discussions
  • 7,870,480 Comments

Discussions

Running a Java procedure from an Oracle procedure by defining it as an Oracle procedure

rjsosi
rjsosi Member Posts: 217 Bronze Badge

Hi, we using Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production.

I've loaded the OS_COMMAND package in Oracle and I see it's all java.

The procedure I'm most interested in is the one that allows users to run a Linux command from with in an Oracle procedure. It's defined as the following: ex 1

 procedure set_exec_in_shell
 is language java name 'ExternalCall.useShell()';

How can I define this in an Oracle procedure in order for it to run as an Oracle function?

The only example I have is an Oracle procedure that defines a java method to use as an Oracle function. It's the following: ex 2

CREATE OR REPLACE PROCEDURE SLDPROC.shell (p_command IN VARCHAR2)
AS LANGUAGE JAVA 
NAME 'Host.executeCommand (java.lang.String)';
/

Which comes from the following java method: ex 3

 public class Host {
public static void executeCommand(String command) ...
...

So not having used java for a long time(20 yrs), how can I create a similar Oracle procedure to wrap a java procedure like the set_exec_in_shell procedure defined in the first example, ex 1?


Thanks!

Tagged: