aspose file tools*
The moose likes JDBC 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
Bookmark "cant delete frrom table" Watch "cant delete frrom table" New topic
Author

cant delete frrom table

Laura Mike
Greenhorn

Joined: Nov 13, 2003
Posts: 17
hi,
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
Marshal

Joined: Jan 10, 2002
Posts: 60998
    
  65

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


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Laura Mike
Greenhorn

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.


Bosun (SCJP, SCWCD)
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
Sheriff

Joined: Dec 10, 2001
Posts: 7023
In that case...
Laura,
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
Rancher

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
Greenhorn

Joined: Nov 13, 2003
Posts: 17
Thanx friends...
problemis solved....
David was right i did as he directed and am successful in doing the job.it was a missing update problem which i did no knew before.
Thanx again to all helpers....
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: cant delete frrom table