Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to delete a record from a table without a primary key

 
solomon prathap
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
author & internet detective
Marshal
Posts: 34973
379
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
no primary key then must be a unique constraint
 
solomon prathap
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
author & internet detective
Marshal
Posts: 34973
379
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 582
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Maybe you can use code like this



Hope this help...
Correct me if i am wrong

thanks
daniel
 
solomon prathap
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Daniel Fisher

Tnx for ur code.Let me try this code.I will get back to u..
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic