• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

passing values with IN attribute

 
Ranch Hand
Posts: 686
Mac
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a where clause like:"WHERE IB.CURR_CUSTOMER_KEY IN (?)"
Now input values may contain one or more then one values. And the number of customer key can only decided at runtime only so how to pass values in IN attribute.
 
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If your are using prepared statement, u can use
setString(int parameterIndex, String x)

where string x = "Value1,Value2" and parameterIndex = 1
The string x u need to create at runtime.

So ur IN clause will be
Select * from xyz where a.data in ("Value1,Value2")

What do u thing
Am i on right track

Let me know

Regards
Makarand Parab
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Makarand,
That won't work. You can only substitute a single string literal for the parameter. So the database would try to match on "Value1,Value2" rather than "Value1" and "Value2."

Jignesh,
Take a look at this thread where I explain select batching a bit. Interestingly, this is the topic of an article for the October JavaRanch Journal. The article will go into more depth on the topic, walk through an example and point out some criteria to use.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic