Win a copy of Escape Velocity: Better Metrics for Agile Teams this week in the Agile and Other Processes forum!
  • 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
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

deleting multiple comma separated values in one attempt

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
I want to delete few records from a table whose id's will be passed at run time i want this operation to be done at once
can i have a method to do so
delete from tablename where id /in = HERE I HAVE TO PASS , SEPARATED MULTIPLE VALUES using jdbc

Thanks
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"shanu",

We're a friendly bunch at the Ranch, but we require members to have real display names.

Please see your previous warning here.

We require display names to be two words: your first name, a space then your last name. Fictitious names are not allowed.

You can change your display your display name here.

thanks,
Dave.
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Probably the easiest is to use a sql batch, since you can also use a PreparedStatement. Performance is typically very good (whatever that means)

or you can use

delete from my_table where table_id in (1, 2, 3, 4, etc);

If they are string values you will need single quotes:

delete from my_table where table_id in ('1', '2', '3', '4', etc);
 
The airline is called "Virgin"? Don't you want a plane to go all the way? This tiny ad will go all the way:
Garden Master Course kickstarter
https://coderanch.com/t/754577/Garden-Master-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic