passing arrays to oracle

Stu Johns

Ranch Hand

Posts: 63

posted 7 years ago

Hi,
I am trying to pass an array of Strings to insert into an oracle table in 1 hit.
I have defined types in oracle:

and have written the code:

However I get an error when i try and run it:
Exception in thread "main" java.sql.SQLException: Fail to convert to internal representation: v4
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:146)
at oracle.jdbc.oracore.OracleTypeADT.toDatum(OracleTypeADT.java:239)
at oracle.jdbc.oracore.OracleTypeADT.toDatumArray(OracleTypeADT.java:274)
at oracle.jdbc.oracore.OracleTypeUPT.toDatumArray(OracleTypeUPT.java:115)
at oracle.sql.ArrayDescriptor.toOracleArray(ArrayDescriptor.java:1314)
at oracle.sql.ARRAY.<init>(ARRAY.java:152)
at TestArray.main(TestArray.java:63)

Anyone got any ideas how to do an insert with an array in oracle?

thanks

Lorand Komaromi

Ranch Hand

Posts: 276

posted 7 years ago

Stu Johns wrote: I have defined types in oracle:

I don't have much experience with Oracle, so this could be wrong, but shouldn't col1 be of type array_of_persons..?