I have a PL/SQL stored procedure similar to the following that I need to call in Java:
TYPE AssocArrayVarchar20_t is table of VARCHAR2(20) index by BINARY_INTEGER
TYPE AssocArrayVarchar4100_t is table of VARCHAR2(4100) index by BINARY_INTEGER
TYPE AssocArrayNumber_t is table of NUMBER index by BINARY_INTEGER
PROCEDURE DATA_WRITE( I_NAME IN AssocArrayVarchar20_t,
I_NUM IN AssocArrayNumber_t,
I_NOTE IN AssocArrayVarchar4100_t)
// Do Stuff
END DATA_WRITE;
I tried the following in Java:
CallableStatement stmt = conn.prepareCall("begin DATA_WRITE(?, ?, ?); end;");
stmt.setArray(0, conn.createArrayOf("VARCHAR", new String[]{ name }));
stmt.setArray(1, conn.createArrayOf("NUMBER", new Integer[]{ num }));
stmt.setArray(2, conn.createArrayOf("VARCHAR2", new String[]{ notes }));
stmet.execute;
When I do this I get a SQLException: Unsupported Feature"
on the createArrayOf()
method. I've also tried setObject()
and inside of createArrayOf
: "varchar"
, "AssocArrayVarchar20_t"
, "varchar_t"
. Nothing seems to change that outcome.
Does anyone know what I'm doing wrong? I can't seem to get it to work.
UPDATE: Success!
OracleCallableStatement pStmt = (OracleCallableStatement) conn.prepareCall("begin DATA_WRITE(?, ?, ?); end;");
pStmt.setPlsqlIndexTable(1, new String[]{ name }, 1, 1, OracleTypes.VARCHAR, 20);
pStmt.setPlsqlIndexTable(2, new Integer[]{ num }, 1, 1, OracleTypes.NUMBER, 0);
pStmt.setPlsqlIndexTable(3, new String[]{ notes }, 1, 1, OracleTypes.VARCHAR, 4100);
pStmt.execute();