Purpose : To demonstrate that Oracle database has an embedded JVM Objective: PL/SQL is great, but it is an Oracle Proprietary language that cannot be ported to other database platforms,, Java is portable Environment : The example uses SQL*Plus, but other tools also work Oracle Version: I Used Oracle9i, Oracle8i should work similarly SQL> CREATE OR REPLACE and RESOLVE JAVA SOURCE NAMED "Hello" AS SQL>SELECT hello (ENAME) from EMP;
public class Hello {
static public String Msg(String tail) {
return "Hello " + tail;
}
}
/
Java created.
SQL> CREATE OR REPLACE FUNCTION hello( str VARCHAR2 )
RETURN VARCHAR2 AS
LANGUAGE JAVA NAME
'Hello.Msg (java.lang.String)
return java.lang.String';
/
HELLO(ENAME)
-----------------------------
Hello SMITH
Hello ALLEN
Hello WARD
Hello JONES
Hello MARTIN
Hello BLAKE
Hello CLARK
Hello SCOTT
Hello KING
Hello TURNER
Hello ADAMS
HELLO(ENAME)
-----------------------------
Hello JAMES
Hello FORD
Hello MILLER
Friday, January 18, 2008
Oracle Stored procedures JAVA
Subscribe to:
Post Comments (Atom)
1 comment:
Thanks a lot for sharing the complete source code to prove that database has embedded JVM in it. I am using Oracle 10g hope this code will work on that version too. I will first implement the code and will get back to you if any error occurs.
sap upgrade
Post a Comment