It depends on the database you are using.
If using oracle, then you can create a new datatype in database to store
array of numbers(if you require to work with 
Collection of number)

Then you can pass a array of numbers to stored proc using the setArray
method


The code snippet is as follows:

--Creating a type (a datatype stored in database)
CREATE OR REPLACE TYPE ENT_GENERIC_NUMBER_TYPE AS TABLE OF number;


--In java layer suppose you have a collection of integer objects (say
numlist)
  ArrayDescriptor numberArrDescriptor =
ArrayDescriptor.createDescriptor("ENT_GENERIC_NUMBER_TYPE",
 
connection);
  Array numarray = new Array(numberArrDescriptor,connection,
numlist.toArray());

Preparedstatement.setArray(1, numarray);


-- DB layer accessing the  array
PROCEDURE arraytester (
      numarray in    ent_generic_number_type,
   )
Is
Begin
        FOR i IN numarray.FIRST .. numarray.LAST
        Loop 
          dbms_output.put_line(numarray(i));
        End loop;
End;



Similarly you can create type of any oracle
datatype(number,date,varchar2)

Hope it helps

Thanks,
Satish Kataria

-----Original Message-----
From: CRANFORD, CHRIS [mailto:[EMAIL PROTECTED] 
Sent: Thursday, June 24, 2004 9:07 PM
To: '[EMAIL PROTECTED]'
Subject: Arraylists/Collections


Is there a proper way to pass an arraylist/collection to a pl/sql
procedure besides turning it into a string on the java-side and passing
it then as a VARCHAR parameter?

_______________________________________________________
Chris Cranford
Programmer/Developer
SETECH Inc. & Companies
6302 Fairview Rd, Suite 201
Charlotte, NC  28210
Phone: (704) 362-9423, Fax: (704) 362-9409, Mobile: (704) 650-1042 
Email: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to