Home » Developer & Programmer » JDeveloper, Java & XML » call a Java function with a (array of) complex data type
call a Java function with a (array of) complex data type [message #527908] Thu, 20 October 2011 14:37 Go to next message
dassany
Messages: 1
Registered: October 2011
Junior Member
Hallo,

I'm trying to call a Java function from within a PL/SQL aggregation function with a (array of) complex data type.


a) basic definitions (work and are ok)

CREATE OR REPLACE TYPE eventtype AS OBJECT
(
	relevance NUMBER,
	bid1 NUMBER,tid1 NUMBER,prob1 NUMBER,
	bid2 NUMBER,tid2 NUMBER,prob2 NUMBER,
	bid3 NUMBER,tid3 NUMBER,prob3 NUMBER,
	bid4 NUMBER,tid4 NUMBER,prob4 NUMBER,
	bid5 NUMBER,tid5 NUMBER,prob5 NUMBER,
	bid6 NUMBER,tid6 NUMBER,prob6 NUMBER
);

CREATE OR REPLACE TYPE eventtuple IS TABLE OF eventtype;
/



b) The following call works (but is not exactly that what I want):

public class pcompDP {
	public static NUMBER probComputation(oracle.sql.STRUCT pin) throws java.sql.SQLException {
		...
	}
}

create or replace FUNCTION pcompDPFunc(cin IN eventtype) RETURN NUMBER PARALLEL_ENABLE DETERMINISTIC AS LANGUAGE JAVA NAME 'pcompDP.probComputation(oracle.sql.STRUCT) return BigDecimal';
/

SELECT pcompDPFunc(eventtype(5, 6, 0.3, 10, 20, 0.45, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)) from dual;




c) The following call doesn't work (but should have the intended semantics):

public class pcompDP {
	public static NUMBER probComputation(oracle.sql.STRUCT[] pin) throws java.sql.SQLException {
		...
	}
}

create or replace FUNCTION pcompDPFunc(cin IN eventtype) RETURN NUMBER PARALLEL_ENABLE DETERMINISTIC AS LANGUAGE JAVA NAME 'pcompDP.probComputation(oracle.sql.STRUCT[]) return BigDecimal';
/

SELECT pcompDPFunc(eventtuple(eventtype(2, 3, 0.234, 1, 1, 0.123, 0, 0, 0, 0, 0, 0, 0, 0, 0), eventtype(5, 6, 0.3, 10, 20, 0.45, 0, 0, 0, 0, 0, 0, 0, 0, 0))) from dual;



d) What's the error? Do I have to use JPublisher or is it possible without it? I guess an array should be possible without it.

The type of the parameter seems to be wrong. Question is whether in PL/SQL, Java or SQL.

Thanks in advance,
Sascha

[Updated on: Thu, 20 October 2011 14:41]

Report message to a moderator

Re: call a Java function with a (array of) complex data type [message #527909 is a reply to message #527908] Thu, 20 October 2011 14:40 Go to previous message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
http://www.lmgtfy.com/?q=oracle+CALL+JAVA+FUNCTION
Previous Topic: Process XML data passed in parameter
Next Topic: Offline DataBase
Goto Forum:
  


Current Time: Fri Mar 29 05:40:57 CDT 2024