Creating a function in an Oracle database using java directly

I understand that you can create a java function in the oracle database using the CREATE JAVA command - see here . I read a lot about how to do this, but the more I read, the more I read.

What I want to do is simple. Since I am already very familiar with Java, I do not want to learn PL / SQL, especially that the project I'm working on is pretty small. I also do not want to do too much with this function, all I want to do is something like the following:

1) Declare a function when connecting to the database, for example:

CREATE JAVA AS 
    public class Example{
        public static bool returnTrue() {
            return true;
        }
    }

2) Then call the function when connected as:

SELECT Example.returnTrue() FROM DUAL;

Is it possible?
How?

+3
source share
2 answers

, :

( , SQL . SQL SQL, - String).

:

create or replace and compile java source named returntrue as
public class example
{ public static String returnTrue() { return "TRUE"; } };

"" PL/SQL java- PL/SQL:

SQL>     CREATE OR REPLACE FUNCTION returnTrue
  2      RETURN VARCHAR2
  3      AS LANGUAGE JAVA
  4      NAME 'example.returnTrue() return java.lang.String';
  5  /


Function created

SQL> select returntrue from dual;

RETURNTRUE
--------------------------------------------------------------------------------
TRUE

Oracle.

+8

Oracle? " " " ", PL/SQL. , , , SQL. , , , " SQL", . JVM JDBC, .

+3

All Articles