Re: Need java.sql.Array impl for PreparedStatement.setArray()
Posted by: Yogesh Gadge
Date: January 22, 2006 09:39AM

sam504u wrote:
>
> How do you know what is the size of the largest
> Array ??? In dynamic applications ... the number
> of elements will vary from call to call.
>
> I have been looking for a way to call a SP using
> CallableStatement in Java wherein I can pass an
> array of Integers (or String) For Ex: int array[]
> = {1,2,3};
>
> for the same purpose as tauron before was
> mentioning how do we do
>
> SELECT id FROM table WHERE x IN (1,2,3) ???
>
> -Sam

Unfortunately you will have to pass a comma seperated values as string to your SP and write SP accordingly.

If you think that your number of elements will vary greatly and that the number is quite big most of the time (say 1000 - 10000 elements in IN clause) you should seriously consider temp table for that.

But if you know that your number of calls vary between 1-1000 just use 1000 question marks if you are using prepared statements otherwise construct SQL on fly.



Edited 1 time(s). Last edit at 01/22/2006 09:39AM by Yogesh Gadge.

Options: ReplyQuote




Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.