15-7. Passing Parameters Between PL/SQL and Java

Problem

You want to pass parameters from PL/SQL to a Java stored procedure that expects them.

Solution

Create a call specification that accepts the same number of parameters as the number the Java stored procedure expects. For this example, an additional method will be added to the Employee Java class that was created in Recipe 15-1. This method will be an enhanced version of the original method that will accept a department ID as an input argument. It will then query the database for the employees who belong to that department and display them.

The following code is the enhanced Java method that will be added the Employees class contained within the Employees.java file:

public static void getItEmpsByDept(int ...

Get Oracle and PL/SQL Recipes: A Problem-Solution Approach 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.