If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > JAVA > Passing an ARRAY object to Oracle Stored Procedure

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-28-09, 21:37
ananthvg ananthvg is offline
Registered User
 
Join Date: Jan 2009
Posts: 1
Passing an ARRAY object to Oracle Stored Procedure

Hi All,

I have a packaged procedure which has the parameters as,

PROCEDURE process_adjustment (p_adj IN NUMBER,p_adjustmentvalue IN adjustment_value, p_doubleentry_array IN DOUBLE_ENTRY_ARRAY)

DOUBLE_ENTRY_ARRAY is declared as,

CREATE OR REPLACE
type DOUBLE_ENTRY_ARRAY as table of DOUBLEENTRY_VALUE

DOUBLEENTRY_VALUE is defined as

Point is that i have to call the packaged procedure process_adjustment from java,

I am using the oracle.sql.ARRAY implementation.

Java code:

connection=ejbGlossary.getOracleConnection();
conn1 = (OracleConnection) connection;
stmt = null;
stmt = conn1.prepareCall("{call pkg_process_adjustments_v1.process_adjustment(?,?, ?)}");
( (OraclePreparedStatement) stmt).setLong(1,adjustmentKey);
( (OraclePreparedStatement) stmt).setObject(2, adjustmentValue, OracleTypes.STRUCT);
AdjustmentDoubleEntryValue[] arrDoubleEntry = (AdjustmentDoubleEntryValue[]) doubleEntries.toArray(new AdjustmentDoubleEntryValue[]{});
ArrayDescriptor descriptor = ArrayDescriptor.createDescriptor( "DOUBLE_ENTRY_ARRAY", conn1 );
ARRAY array_to_pass = new ARRAY( descriptor, conn1, arrDoubleEntry);
( (OraclePreparedStatement) stmt).setARRAY(3,array_to_pass);
( (OraclePreparedStatement) stmt).execute();

while executing i get the following error,


Caused by: java.sql.SQLException: Fail to construct descriptor: Invalid arguments
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBE rror.java:134)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBE rror.java:179)
at oracle.jdbc.dbaccess.DBError.check_error(DBError.j ava:1130)
at oracle.sql.StructDescriptor.createDescriptor(Struc tDescriptor.java:125)
at oracle.sql.STRUCT.toSTRUCT(STRUCT.java:614)
at oracle.jdbc.oracore.OracleTypeADT.toDatum(OracleTy peADT.java:241)
at oracle.jdbc.oracore.OracleTypeADT.toDatumArray(Ora cleTypeADT.java:302)
at oracle.jdbc.oracore.OracleTypeUPT.toDatumArray(Ora cleTypeUPT.java:117)
at oracle.sql.ArrayDescriptor.toOracleArray(ArrayDesc riptor.java:1517)
at oracle.sql.ARRAY.<init>(ARRAY.java:117)
at com.db.ember.server.session.adjust.AdjustmentProce ssBean.processAdjustment(AdjustmentProcessBean.jav a:123)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at com.inprise.ejb.ConcreteMethod.invoke(ConcreteMeth od.java:32)
at com.inprise.ejb.EJBContext.invoke(EJBContext.java: 209)
at com.inprise.ejb.Dispatcher.doInvoke(Dispatcher.jav a:1530)
at com.inprise.ejb.Dispatcher.invokeJACCSecurityCheck (Dispatcher.java:1138)
at com.inprise.ejb.Dispatcher.invokeSecurityCheck(Dis patcher.java:1148)
at com.inprise.ejb.Dispatcher.invoke(Dispatcher.java: 893)
at com.inprise.ejb.Dispatcher.invoke(Dispatcher.java: 665)
at com.inprise.ejb.EJBHome.dispatcherInvokeBeanMethod (EJBHome.java:85)
at com.inprise.ejb.EJBHome$ComponentInterfaceMethodCa che.invokeDispatcherMethod(EJBHome.java:1571)
at com.inprise.ejb.EJBHome.invokeDispatcherMethod(EJB Home.java:63)
at com.inprise.ejb.Dispatcher.invoke(Dispatcher.java: 469)


Can any one help me to fix this issue?

Thanks,
Ananth G
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On