This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Java in General and the fly likes Retaining DB values as well as Dynamically generated Values.. Help  Needed ! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Retaining DB values as well as Dynamically generated Values.. Help  Needed !" Watch "Retaining DB values as well as Dynamically generated Values.. Help  Needed !" New topic
Author

Retaining DB values as well as Dynamically generated Values.. Help Needed !

Bunty Jha
Greenhorn

Joined: May 22, 2008
Posts: 2
In my application i have a list of records coming from database (DB)

say 'Family members' of an employee

it appears on page like :

sl no. member_name relation Action
1johnson delete
2marrydaughter delete

[Add Another Family Member]

Now we have an option of dynamically adding a row

Problem :

1 . suppose I add 4 more family members till serial number 6 (2 records are already exists in database )
and then deleteany one of records by clicking action delete button for corresponding row , it deletes that entry from database but also all entries that were dynamically added
also gets lost due to page reload .
how to retain the dynamically entered values ??


2 . here comes one more issue , i have a serial number column in database and employee code as PK ,
now the requirement is if any record in middle is deleted , the serial numbers must maintain order .. i.e if record having sl no 3 is deleted
the the subsquent records must be re numbered as 3,4,5 ...

How to renumber the serial numbers ?


Please do help ,

thanks
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 37900
    
  22
Welcome to JavaRanch

Have you really got the serial numbers as a composite PK and wich to change the serial numbers? That's not possible, surely?

How about creating a view or temporary table with the details you require, select and order by serial number, then add a new row number?

Please ask Rob or Ernest to transfer this thread to the JDBC forum.
Bunty Jha
Greenhorn

Joined: May 22, 2008
Posts: 2
Thanks for your suggestion .

what can i do for problem 1.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 37900
    
  22
To solve problem 1: redesign your database to take the serial number out of the PK.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Retaining DB values as well as Dynamically generated Values.. Help Needed !
 
Similar Threads
NX: URLyBird questions about database
edit and delete operations Datatable In MY faces
Bodgitt & Scarper - Database Record Numbering
I Can still be wrong?, or no? (almost complete my assignment)
My locking approach...comments please