Nacho321
Nacho321

Reputation: 1991

Mapping type for JDBC call

There is an SQL DB that has this PROCEDURE

PROCEDURE sendEmail (p_subject IN VARCHAR2,
                     p_sender_name IN VARCHAR2,
                     p_sender_email IN VARCHAR2,
                     p_sub_service IN VARCHAR2,
                     p_recepient_email IN VARCHAR2,
                     p_recepient_name IN VARCHAR2,
                     p_template_name IN VARCHAR2,
                     p_template_variables IN t_fields,
                     p_template_locale IN VARCHAR2,
                     p_success OUT BOOLEAN,
                     p_message OUT VARCHAR2);

The t_fields type is defined like this:

TYPE t_fields IS TABLE OF VARCHAR2(2000) INDEX BY VARCHAR2(100);

I am using JDBC to make a call to that procedure, and I know that I need a connection and a callStmt, but I am unsure of how to deal with the t_fields parameter mapping. Any pointers?

Upvotes: 2

Views: 154

Answers (1)

roymustang86
roymustang86

Reputation: 8553

t_fields is an associate array. Think of it like a PL/SQL way of defining arrays.

All PLSQL arrays can not be called from java. An array needs to be created as TYPE, at SCHEMA level in the database and then it can be used with ArrayDescriptor in Java, as oracle.sql.ArrayDescriptor class in Java can not access at package level.

Here is a link which shows you how to do it:

http://viralpatel.net/blogs/java-passing-array-to-oracle-stored-procedure/

Upvotes: 1

Related Questions