Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> Type problems with PL/SQL function as a Java wrapper.

Type problems with PL/SQL function as a Java wrapper.

From: Jesse, Rich <Rich.Jesse_at_qtiworld.com>
Date: Tue, 04 Jun 2002 09:08:30 -0800
Message-ID: <F001.00473A71.20020604090830@fatcity.com>


Hey all,

Trying to get into this new fangled "Java" thingy in 8.1.7.2.0 on HP/UX. Simple OS exec test, mostly plagarized:

// qlp.java

import java.lang.Runtime;
import java.lang.Process;
import java.io.IOException;
import java.lang.InterruptedException;

public class qlp {

        public static int main(String args) {

        int retval = 0;

	try {
		String	lpCommand;
		lpCommand = "/usr/bin/lp " + args;

		Process p = Runtime.getRuntime().exec(lpCommand);

		try {
			p.waitFor();

	     } catch (InterruptedException intexc) {
		System.out.println("Interrupted Exception on waitFor: " +
intexc.getMessage());
	     }

	retval = p.exitValue();

	} catch (IOException e) {
		e.printStackTrace();
	}

	return (retval);

   }
}

// End of Java code

I run javac to compile it, then loadjava the class file into the DB. I can then create a PL/SQL procedure as a wrapper:

CREATE OR REPLACE PROCEDURE qlp_proc (file_and_parms IN VARCHAR2) AS LANGUAGE JAVA
NAME 'qlp.main (java.lang.String[])';
/

And it works, but I need to test for success/fail. But if I try a FUNCTION wrapper:

CREATE OR REPLACE FUNCTION qlp_func (file_and_parms IN VARCHAR2) RETURN NUMBER
AS LANGUAGE JAVA
NAME 'qlp.main (java.lang.String[]) return int';
/

I get PLS-00311: the declaration of "qlp.main (java.lang.String[]) return int" is incomplete or malformed.

Two questions: 1) Every example I've seen of the wrapper excludes the brackets from the java.lang.String parameter def, but I can't get a compile without it. Why? And 2) Anyone know what's wrong with my FUNCTION def?

Desperately needing a good Java tutorial, too!

TIA!

Rich Jesse                           System/Database Administrator
Rich.Jesse_at_qtiworld.com              Quad/Tech International, Sussex, WI USA
-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.com
-- 
Author: Jesse, Rich
  INET: Rich.Jesse_at_qtiworld.com

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: ListGuru_at_fatcity.com (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).
Received on Tue Jun 04 2002 - 12:08:30 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US