Thanks for the post - I'm going to try this out and let you know how it worked
Main Topics
Browse All TopicsHello,
I'm looking for a java code example doing a delete from a db2 database table using a cursor. I have a table with loads of data in it that I need to clean out using a cursor.
My old program simply issued the statement:
delete from TABLENAME where FIELDNAME < '2005-10-01-00.00.00.00000
Something like that. But - problem is there's too much data that qaulifies for deltion and the transaction logs fill up. So DBAs tell me I need to use a cursor to do the delete. This is something new to me!
Thanks in advance for your sample code
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
yeah the result set scrolling will open a cursor on the db (depending on the database and driver).. This is the only way to do this type of thing efficiently in java. You will still probably want to run inside of a transaction and commit every xx number of rows though, this way the transaction logs won't fill up.
Here is a link that should get you started with the transactions.. (http://java.sun.com/docs/
Business Accounts
Answer for Membership
by: matthewdflemingPosted on 2005-10-12 at 09:52:36ID: 15070616
Connection con = DriverManager.getConnectio n("jdbc:my Subprotoco l:mySubNam e"); Set.TYPE_S CROLL_SENS ITIVE, ResultSet.CONCUR_UPDATABLE );
Statement stmt = con.createStatement(Result
ResultSet uprs = stmt.executeQuery("SELECT * FROM table_to_delete");
while (uprs.next()) {
uprs.deleteRow();
}