I am trying to return an associative array to java but facing exceptions. I am using a proprietary persistence layer so I won't be able to post my code but while searching on google I found something which is exactly similar to what I have:
===========================
create or replace PACKAGE testLookAside as
type AssocArry IS TABLE OF varchar(30) INDEX BY VARCHAR(30);
function lookupMasterData return AssocArry;
end testLookAside;
/
create or replace PACKAGE BODY testLookAside as
function lookupMasterData_ return AssocArry as
retval AssocArry;
begin
retval('1') := '1';
retval('2') := '2';
retval('3') := '3';
retval('4') := '4';
return retval;
end lookupMasterData_;
/
function lookupMasterData return AssocArry as
retVal AssocArry;
begin
retVal := lookupMasterData_();
return retVal;
end lookupMasterData;
end testLookAside;
Statement s = null;;
Class.forName("oracle.jdbc.driver.OracleDriver");
// set up connection here....
s=con.createStatement();
//String query = "begin ? := DEVELOPER.testLookAside.lookupMasterData(); end;";
String query = "{? = call DEVELOPER.testLookAside.lookupMasterData()}";
OracleCallableStatement stmt = (OracleCallableStatement)con.prepareCall(query);
// register the type of the out param - an Oracle specific type
stmt.registerIndexTableOutParameter(1, 30, OracleTypes.VARCHAR, 30);
stmt.execute();
And I kept getting errors like:
Exception in thread "main" java.sql.SQLException: ORA-06550: line 1, column 13:
PLS-00382: expression is of wrong type
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
Could anyone explain what the right way is to access that datatype from jdbc?
Also, what should I do if my custom type uses number and binary integer like this:
type AssocArry IS TABLE OF NUMBER INDEX BY BINARY_INTEGER;
I am trying to solve this problem from last one week and looked into numerous threads with no results.
Thanks.
Oracle 12c JDBC Developer guidehere: docs.oracle.com/database/121/JJDBC/oraint.htm#JJDBC28179 but Oracle 11.2 documentation doesn't mention them anywhere, could be that older versions of the database and the driver simply don't support them.