File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes cant delete frrom table 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 "cant delete frrom table" Watch "cant delete frrom table" New topic

cant delete frrom table

Laura Mike

Joined: Nov 13, 2003
Posts: 17
i want to delete a record from the table "myTab" and using this query.but when i run the prog. it executes without eror but the deletion is not performed in the table.wt is the problem plz help.
my query is:
UPDATE myTab SET flag = true WHERE id = 4
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63852

Why would you expect an UPDATE op to perform a delete? Perhaps a DELETE op would be more effective?

[Asking smart questions] [About Bear] [Books by Bear]
Laura Mike

Joined: Nov 13, 2003
Posts: 17
i know but i want to do it with update for some reason.
am i doing it in wrong way?
Bosun Bello
Ranch Hand

Joined: Nov 06, 2000
Posts: 1510
Bear already asked why you would expect and UPDATE to delete/remove a record from a table. Am I missing something? After executing your statement the record will still be in the table. You still need a DELETE statement to remove it from the table. If you are new to SQL and/or relational databases in general, you will need a tutorial.

So much trouble in the world -- Bob Marley
Thomas Paul
mister krabs
Ranch Hand

Joined: May 05, 2000
Posts: 13974
Some people do use flags to mark a record as "deleted". I wrote at least one system that I can recall where we never deleted anything but simply used a flag to identify a record as no longer being available. We then gacve the users a special screen they could use to recover "deleted" records. The users thought we were magicians!

Associate Instructor - Hofstra University
Amazon Top 750 reviewer - Blog - Unresolved References - Book Review Blog
Dirk Schreckmann

Joined: Dec 10, 2001
Posts: 7023
In that case...
Why do you think that your posted example UPDATE statement isn't working? Are you receiving an error message? If so, what is it? Or does the proper record seem to not actually be updated?

[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
Anurag Gupta
Ranch Hand

Joined: Dec 13, 2001
Posts: 40
Soft delete is good option for certain aplication - by flaging a Record as Deleted , though it remains in the DataBase.
Check whether u are committing the record after update is fired.
Check whether the Record exists in the Table, which u r trying to update.
David O'Meara

Joined: Mar 06, 2001
Posts: 13459

can we get more info on your setup?
if you're using Access or the JDBC-ODBC bridge I'd say it could be the common 'missing update' problem. Try executing an dummy select after your update to 'flush' the connection.
Laura Mike

Joined: Nov 13, 2003
Posts: 17
Thanx friends...
problemis solved....
David was right i did as he directed and am successful in doing the was a missing update problem which i did no knew before.
Thanx again to all helpers....
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: cant delete frrom table
It's not a secret anymore!