• 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

Problem with IN clause

 
Ranch Hand
Posts: 154
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Thanks in advance.
I would like to pass a comma separated string to my stored procedure. When I send a single value it is working correctly however If I pass more than one it is not returning any parameter in JDBC.
Example:
I have a select query which uses in like ‘select name from where roll_no in (‘10a’,’10e’,’11j’);
I have java variable to hold this comma separated value.

Please guide me.

Thanks,
Sree
 
Ranch Hand
Posts: 144
Oracle Fedora Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can you post the code you are using so far?
 
sreedhar Lackka
Ranch Hand
Posts: 154
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Thanks for your reply.

The high level code looks like below,


The proc will accept this in parameter, and perform select with in caluse

select name from xsdr where num in (varName)

here varName is the value sent from Java

Thanks
Sree

 
Mike Zal
Ranch Hand
Posts: 144
Oracle Fedora Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
After your call on line 3, the StringBuffer contains "11B10A". If you intended to have them comma separated you need to append that as well


I'm not sure how stored procedure will react to the comma separated list; you may want to try testing it from the database command line. You might want to consider overloading the test_proc procedure to take an Array of values instead of trying to stuff multiple values into one varchar parameter.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic