tags:

views:

168

answers:

1

I´m a little bit frustrated with my Java environment that didn´t allow me to call the method OraclePreparedStatement#setPlsqlIndexTable ... but i think i should write the code before...

String plSqlBody = "some pl/sql procedure call"
/*
 * The PL/SQL procedure parameter is here of type
 * TYPE t_date_table IS TABLE OF DATE INDEX BY PLS_INTEGER;
 */
OracleCallableStatement ocs = (OracleCallableStatement)
        conn.prepareCall(plSqlBody);
java.util.Date[] date = new java.util.Date[10];
// Initialise the array... and then...
ocs.setPlsqlIndexTable(index, date, 20, 20, OracleTypes.DATE, 20);

And here i get my exception:

java.sql.SQLException: Ungültiger PL/SQL-Indextabellen-Elementtyp
at oracle.jdbc.driver.SQLStateMapping.newSQLException(SQLStateMapping.java:70)

I didn´t find a solution for the problem. I changed the Java type from java.util.Date to java.sql.Date / oracle.sql.DATE and OracleTypes.DATE to OracleTypes.TIME / OracleTypes.TIMESTAMP, but nothing solved the problem. I find somewhere the hint, that these types are not allowed here, but i can´t believe it. Do you know the right way here?

+1  A: 

From the Oracle docs (JDBC Developer's Guide, JDBC OCI Extensions chapter):

Oracle JDBC does not support RAW, DATE, and PL/SQL RECORD as element types.

Maybe you could pass the dates in as strings/numbers instead?

SimonJ
It seems so. +1
Adeel Ansari
That would by an uncomfortable solution. I don´t know the reason, why Oracle´s JDBC driver does not support DATE here.I saw the same problem at a C# project. The Oracle .NET driver there seems to allow to pass an array of TIMESTAMP objects to the procedure. But i´m not an .NET expert.
andrewinkler