aspose file tools*
The moose likes JDBC and the fly likes need help :: multiple rows update without primary key Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "need help :: multiple rows update without primary key" Watch "need help :: multiple rows update without primary key" New topic
Author

need help :: multiple rows update without primary key

Revanth reddy
Ranch Hand

Joined: Oct 10, 2008
Posts: 52
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
internet detective
Marshal

Joined: May 26, 2003
Posts: 30537
    
150

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)


[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
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
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

Joined: Oct 10, 2008
Posts: 52
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

Joined: Oct 10, 2008
Posts: 52
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

Joined: Apr 14, 2004
Posts: 10336


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.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30537
    
150

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?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: need help :: multiple rows update without primary key