This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes JDBC and Relational Databases and the fly likes deleting multiple comma separated values in one attempt Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "deleting multiple comma separated values in one attempt" Watch "deleting multiple comma separated values in one attempt" New topic
Author

deleting multiple comma separated values in one attempt

shahin Khan
Greenhorn

Joined: Mar 04, 2005
Posts: 17
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
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

"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

Joined: Mar 06, 2001
Posts: 13459

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);
 
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
 
subject: deleting multiple comma separated values in one attempt
 
It's not a secret anymore!