I am working with a PL/SQL developer on a project. The other developer is writing the stored procedures I need to call.
One of the stored procedures needs to return everything about a product:
name, price, description, color,
weight, manufacturer, etc – ( 15
pieces of info in total )
I assumed that the stored procedure would accept one IN parameter, the product-id and return 15 OUT parameters.
Is there a way that the stored procedure can return an object that I can cast to a custom datatype? Is this a typical technique, or would you normally return multiple OUT parameters?
My preference would be that the procedure (or if it is just retrieving the product information, a function) returned a PL/SQL product object that the Java code retrieves either as a java.sql.STRUCT or as a more strongly typed object.
Oracle has sample code for both approaches on its web site. Here is an example of the java.sql.STRUCT approach. And here is the strongly typed object approach. The strongly typed example uses JPublisher to create the strongly typed object classes but the JDBC Developer’s Guide walks you through creating your own mappings.