| Author |
How to delete a record from a table without a primary key
|
solomon prathap
Greenhorn
Joined: Nov 03, 2004
Posts: 3
|
|
|
i want ideas to delete a record or set of records from a table using JDBC.Primary keys are not specified in the table.Can anybody tell me the logic for it.
|
 |
Jeanne Boyarsky
internet detective
Marshal
Joined: May 26, 2003
Posts: 26192
|
|
Solomon, How would you uniquely identify the record(s) to delete? Try describing this in words first. It can involve one or more columns. Then you can use SQL to delete. Welcome to JavaRanch.
|
[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
|
 |
Adeel Ansari
Ranch Hand
Joined: Aug 15, 2004
Posts: 2874
|
|
no primary key then must be a unique constraint
|
 |
solomon prathap
Greenhorn
Joined: Nov 03, 2004
Posts: 3
|
|
Originally posted by Jeanne Boyarsky: Solomon, How would you uniquely identify the record(s) to delete? Try describing this in words first. It can involve one or more columns. Then you can use SQL to delete. Welcome to JavaRanch.
My problem is,I have 11 attributes in a table.There are 4 foriegn keys,no pk's.I have to delete a set of records(more than one ,at a time) ,by using composite keys.I have 3 criteria fields,based upon i have to first get a set of records,then i have to enable the no of checkbox to be ticked.eg.10 records are displayed,i want to delete 5 records ,by a single click.How this can be made ??
|
 |
Jeanne Boyarsky
internet detective
Marshal
Joined: May 26, 2003
Posts: 26192
|
|
Solomon, You need to do this five times if there are five records to delete. Take a look at executeBatch() so you can do this in one database trip.
|
 |
Fisher Daniel
Ranch Hand
Joined: Sep 14, 2001
Posts: 582
|
|
Hi, Maybe you can use code like this Hope this help... Correct me if i am wrong thanks daniel
|
 |
solomon prathap
Greenhorn
Joined: Nov 03, 2004
Posts: 3
|
|
Hi Daniel Fisher Tnx for ur code.Let me try this code.I will get back to u..
|
 |
 |
|
|
subject: How to delete a record from a table without a primary key
|
|
|