| Author |
How does one insert a column value into an existing record?
|
Steve Howerton
Greenhorn
Joined: Oct 18, 2011
Posts: 27
|
|
Hello
I was trying to insert a value into column of my table for the first time.
There is no exception caught or thrown.
but clearly the rowcount on the update is not a value.
Using Apache derby embedded database.
my DAO () just ignores prepared statement because the syntax must be wrong.
How does one insert a column value into an existing record?
prepared statement in question:
Example of the columns of the table. Please find the book_status as the value I would like to update.
DAO () called:
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19216
|
|
|
Check out how the UPDATE statement works. You need that one to modify any column of existing records. INSERT is only used to create new records.
|
SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
|
 |
Steve Howerton
Greenhorn
Joined: Oct 18, 2011
Posts: 27
|
|
Thanks that was the answer.
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19216
|
|
|
You're welcome.
|
 |
Steve Howerton
Greenhorn
Joined: Oct 18, 2011
Posts: 27
|
|
Is there way to set a param and a proper sql statement to change the value as shown above if I send in the PK ? I noticed my statement now is changing all the records.
I would like to change only one using the primary key.
I tried to bring in the PK and set it but I have a few bugs to work out before I can confirm it works or not.
Is there some code to confirm that something was updated that can be used here?
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19216
|
|
|
executeUpdate returns the number of records that were updated (or inserted / deleted with INSERT / DELETE statements). If that's >0 then you have an updated record.
|
 |
Steve Howerton
Greenhorn
Joined: Oct 18, 2011
Posts: 27
|
|
I was able to update records and change book_status.
Is my code setting the
I do not understand how to set the additional param 'bookNum' .
thanks
|
 |
Paul Clapham
Bartender
Joined: Oct 14, 2005
Posts: 16483
|
|
|
Have you considered the possibility that setting the second parameter would be very much like setting the first parameter? Which you have code for.
|
 |
Steve Howerton
Greenhorn
Joined: Oct 18, 2011
Posts: 27
|
|
I was hoping this to be true. I wanted to eliminate this last step as being the error.
I am in the middle of adding functionality and devising a test and on top of that
I have realized a global var problem concerning MVC2 model design. I will
Add this back in and try to finish debugging this mess.
Thanks
|
 |
 |
|
|
subject: How does one insert a column value into an existing record?
|
|
|