my dog learned polymorphism
The moose likes Oracle/OAS and the fly likes In clause in oracle Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Products » Oracle/OAS
Reply Bookmark "In clause in oracle" Watch "In clause in oracle" New topic
Author

In clause in oracle

Shailesh Narkhede
Ranch Hand

Joined: Jul 10, 2008
Posts: 356
In clause in oracle takes 1000 parameter maximum.
If we give more than that then it is giving exception.

I do not want to use select query inside the IN clause.
Actually I am calling one method. to which I am passing String Array of 1500 PK that I want to use in IN clause.that I am doing by FOR loop and appending to query.
but I do not want change signature of my method.

Please tell us alternative solution.

Thanks in advance.


Thanks,
Shailesh
Sridhar Sreenivasan
Greenhorn

Joined: Dec 08, 2005
Posts: 10
What version of Oracle DB are you using?
"I do not want to use select query inside the IN clause"
Any specific reason of not wanting to use such a solution?

If it's version 11, then based on the information you've provided an alternative solution is to use a select query inside the IN clause as follows:

Assuming the current sql query you have is as follows:
select * from tableA where columnA in(<array of string>);

The above can be modified to
A type "string_type" can be defined as a table of varchar2 in the Oracle DB.
Then the array of string can be assigned to the type variable "string_type_var".
select * from tableA where columnA in(select column_value from table(:string_type_var));

The above solution is efficient and clean.
Shailesh Narkhede
Ranch Hand

Joined: Jul 10, 2008
Posts: 356
Thanks for replay Sridher.
I got it.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: In clause in oracle
 
Similar Threads
How to use Union clause in Hibernate
group by query
how to get limited record in hql?
how to get column information for a given sql string
Fetch multiple keys at one go