So, there I am. 8.1.7.2 with JVM loaded in Oracle. I need to be able to
access the Unix shell from within a procedure, so naturally, I plagiarize
and modify a very simple Java class from somewhere in Metalink:
--- Java code start
import java.lang.Runtime;
import java.lang.Process;
import java.io.IOException;
import java.lang.InterruptedException;
class QT_Exec_OS {
public static int main(String args[]) {
int retval = 0;
try {
String ftpCommand;
ftpCommand = "/usr/bin/ls " + args[0];
Process p = Runtime.getRuntime().exec(ftpCommand);
try {
p.waitFor();
} catch (InterruptedException intexc) {
retval = 700;
}
retval = p.exitValue();
} catch (IOException e) {
e.printStackTrace();
retval = 701;
}
return retval;
}
}
--- Java code end
And then, the PL/SQL wrapper:
--- PL/SQL code start
CREATE OR REPLACE PROCEDURE qt_rjtest (S1 IN VARCHAR2)
AS LANGUAGE JAVA
name 'QT_Exec_OS.main(java.lang.String[])';
/
--- PL/SQL code end
This works fine, but I'm not sure why. According to Metalink, I should be
getting a PLS-311 error because the Java code is returning a value. Hmmmm.
But when I try to create a PL/SQL function to make use of the Java code's
return value:
--- PL/SQL code start
CREATE OR REPLACE FUNCTION qt_rjtest_f (S1 IN VARCHAR2)
RETURN NUMBER
AS LANGUAGE JAVA
name 'QT_Exec_OS.main(java.lang.String[]) return int';
/
--- PL/SQL code end
...I get the PLS-311 "the declaration of
"QT_Exec_OS.main(java.lang.String[]) return int" is incomplete or malformed"
error.
So, I'm guessing that the Java doesn't actually return a value, but I can't
figure out why.
Anyone?
TIA!
Rich Jesse System/Database Administrator
[EMAIL PROTECTED] Quad/Tech International, Sussex, WI USA
--
Please see the official ORACLE-L FAQ: http://www.orafaq.com
--
Author: Jesse, Rich
INET: [EMAIL PROTECTED]
Fat City Network Services -- (858) 538-5051 FAX: (858) 538-5051
San Diego, California -- Public Internet access / Mailing Lists
--------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from). You may
also send the HELP command for other information (like subscribing).