aspose file tools*
The moose likes JDBC 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
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);
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: deleting multiple comma separated values in one attempt