15-10. Passing Data Objects from PL/SQL to Java

Problem

You have retrieved a row of data from the database using PL/SQL, and you want to populate a PL/SQL object type with that data and then pass the populated data object to a Java procedure.

Solution

Create a PL/SQL object type, along with a call specification for the Java stored procedure that you want to pass the object to. Ensure that the Java stored procedure accepts an object of type oracle.sql.STRUCT and that the call specification accepts the PL/SQL object type you have created. For this recipe, the example will demonstrate the creation of a Java method that will accept an Employee object and return that employee's corresponding department name. The Java code will be invoked from within ...

Get Oracle and PL/SQL Recipes: A Problem-Solution Approach now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.