Creating a PL/SQL Wrapper

Once the Java class is loaded into the database, you will need to create a PL/SQL wrapper procedure to call it.

Classes that will be called from PL/SQL have two restrictions:

  • Methods published to SQL and PL/SQL must be declared static. PL/SQL has no mechanisms for instantiating nonstatic Java classes.

  • The classes must not issue any GUI calls (for example, to the AWT, the Abstract Windowing Toolkit) at runtime.

The syntax for creating this procedure is:

CREATE [OR REPLACE] {
   PROCEDURE procedure_name [(param[, param ...])] | 
   FUNCTION  function_name  [(param[, param ...])]
   RETURN plsql_type]}

        [AUTHID {DEFINER | CURRENT_USER}]
        [PARALLEL_ENABLE]
        [DETERMINISTIC]
   {IS | AS} LANGUAGE JAVA
   NAME 'java_method (java_type[, java_type] ...)
   [RETURN java_type];

where param is defined as:

        param := parameter_name [IN | OUT | IN OUT] plsql_type

where:

procedure_name/function_name

Specifies the name you want to give to the PL/SQL wrapper procedure or wrapper function that you are creating.

plsql_type

Specifies the PL/SQL type of a wrapper function’s return value.

AUTHID {DEFINER | CURRENT_USER}

Determines whether the stored subprogram runs with the database privileges of the user who created it (DEFINER) or of the user who invoked it (CURRENT_USER). The default is CURRENT_USER.

PARALLEL_ENABLE

Indicates that the function can be used in slave sessions in parallel DML evaluations. Parallel DML allows DML operations to be spread across multiple processes running in parallel to improve ...

Get Oracle in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.