Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Store array in database

 
Bill Hayes
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need to store an array in an Oracle database. I'm not sure if I should be using blob or clob and more important, I have not been able to find an example of storing an array. Is this even possible?
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34410
346
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bill,
An array of what? The data structure to store depends on what is in the array.
 
Bill Hayes
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'll be storing an array of strings. I know I can simply store a delimted string in a regular varchar field then use StringTokenizer. But storing an array sounded interesting. If coding the storage of array is a really big effort I will probably go the StringTokenizer way. I just wanted to give it one last chance before giving up.
Thanks.
 
Michael Ku
Ranch Hand
Posts: 510
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you serialize the object then you can use a BLOB
 
Purushoth Thambu
Ranch Hand
Posts: 425
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oracle has support for collections. It's very much possible to store the array/collections. You have two options
1. Create new types in oracle and change your JDBC calls to use Oracle specific classes. This might be big effort based on your need.
2. Create new types in oracle and use stored procedure to do all DML and Select.

These links will help you
http://download.oracle.com/docs/cd/B10501_01/java.920/a96654/oraarr.htm
http://download.oracle.com/docs/cd/B10501_01/appdev.920/a96624/05_colls.htm
and other chapters in PL/SQL user guide
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic