• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

need help :: multiple rows update without primary key

 
Revanth reddy
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys,
My requirement is i have to update the table where there is no primary key. the user enters the kitnumber, so we are pulling all the rows for that particular kit number.i have checkboxes for all the rows, and the value for the checkbox is the row id.

when we display the results in a grid, we have to show all the existing data in a text field below each row.

upto this part i am done. i am able to pull the data from table and display in a table and display a textbox below each row with existing data.

my question i have to display the textboxes only when the user clicks on checkboxes.. i have used the <DIV> some how it is not working.

the user clicks on checkboxes we will display the textboxes with existing data...the user can update the checboxes data and clicks on update we need to update the db with new vales..

here my question is how do we pass theses values to DB... i am totally confused.. any help would be greatly appreciated..

here is my jsp

 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34071
331
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Kumar,
The first step is to figure how to uniquely identify a row in the table. You say you don't have a primary key. Do you have any unique combination of columns? (At a minimum, all the columns combined should be unique)
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by kumar kosaraju:
My requirement is i have to update the table where there is no primary key. the user enters the kitnumber, so we are pulling all the rows for that particular kit number.i have checkboxes for all the rows, and the value for the checkbox is the row id.

when we display the results in a grid, we have to show all the existing data in a text field below each row.

upto this part i am done. i am able to pull the data from table and display in a table and display a textbox below each row with existing data.

Fine. Although a PK-less table indicates a bad datamodel.

my question i have to display the textboxes only when the user clicks on checkboxes.. i have used the <DIV> some how it is not working.
That sounds like if the HTML <div> element has some magical working. But it's just a simple block element. Can you please elaborate in detail what you expected of it?

the user clicks on checkboxes we will display the textboxes with existing data...
If you want to do this synchronously, just submit the form and let JSP render the input fields conditionally based on the checkbox value. You can perfectly use JSTL/EL for this. If you want to do this asynchronously, then use Javascript+DOM (DHTML) to display/hide elements during the onclick event of the checkbox.

the user can update the checboxes data and clicks on update we need to update the db with new vales..

here my question is how do we pass theses values to DB... i am totally confused.. any help would be greatly appreciated..
Just by submitting the form to the server and processing the parameters the usual way?

At which step exactly are you stucking while implementing it accordingly? You only stated some functional requirements and said that the <div> "doesn't work". You didn't elaborate in detail about the question/problem with which you're actually struggling. What is the coding problem you're struggling with?
[ December 22, 2008: Message edited by: Bauke Scholtz ]
 
Revanth reddy
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Bauke Scholtz:
Just by submitting the form to the server and processing the parameters the usual way?

At which step exactly are you stucking while implementing it accordingly? You only stated some functional requirements and said that the <div> "doesn't work". You didn't elaborate in detail about the question/problem with which you're actually struggling. What is the coding problem you're struggling with?

[ December 22, 2008: Message edited by: Bauke Scholtz ]



Thankyou so much for your reply.my problem here is the onklick() method is not working. when the page loads i am able to pull the data to grid and showing the values in the textboxes. my requirement is we need to show the textboxes,only when the user clicks on checkbox.
 
Revanth reddy
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Jeanne Boyarsky:
Kumar,
The first step is to figure how to uniquely identify a row in the table. You say you don't have a primary key. Do you have any unique combination of columns? (At a minimum, all the columns combined should be unique)



Unfortunatly none of the combination is unique, so i am using rowid. i want to update the row based on rowid.
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Unfortunatly none of the combination is unique, so i am using rowid. i want to update the row based on rowid.

rowid is not a dependable mechanism - it will change as the data is changed (and its database dependent).

Trying to work with an entity that has no unique identifier is doomed to failure. Make things easy on yourself and add a surrogate key to the table.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34071
331
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by kumar kosaraju:
Unfortunatly none of the combination is unique, so i am using rowid. i want to update the row based on rowid.

Are you saying that you have multiple rows with exactly the same values? If so, why would the user care which one gets updated?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic