Skip to Main Content

Java and JavaScript in the Database

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

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

rjsosiSep 8 2021 — edited Sep 8 2021

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!

Comments

Processing

Post Details

Added on Sep 8 2021
1 comment
829 views