aspose file tools*
The moose likes JDBC and the fly likes passing arrays to oracle Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "passing arrays to oracle" Watch "passing arrays to oracle" New topic
Author

passing arrays to oracle

Stu Johns
Ranch Hand

Joined: Aug 11, 2008
Posts: 63
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

Joined: Oct 08, 2009
Posts: 276
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..?


OCJP 6 (93%)
Anil Kumar Saha
Ranch Hand

Joined: Apr 07, 2004
Posts: 111
Have a look into it. It may help
http://agilej.blogspot.com/2009/05/passing-oraclesqlarray-to-stored.html


Regards,

Anil Kumar Saha
SCJP 1.4
http://www.agilej.blogspot.com/
Stu Johns
Ranch Hand

Joined: Aug 11, 2008
Posts: 63
Thanks folks.
Lorand you were right the columns didnt match.
Anil your example was a great link, I have decided to go the package route for my solution.

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: passing arrays to oracle