aspose file tools*
The moose likes JDBC and the fly likes How to delete a record from a table without a primary key Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "How to delete a record from a table without a primary key" Watch "How to delete a record from a table without a primary key" New topic
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: 29287
    
140

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: 29287
    
140

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..
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to delete a record from a table without a primary key
 
Similar Threads
my result holding null values
hibenate delete problem
Database Circular Reference
SQL Query for two tables joining
JSTL Pagination and Deletion