• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Bunty Jha
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 49865
71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your suggestion .

what can i do for problem 1.
 
Campbell Ritchie
Sheriff
Pie
Posts: 49865
71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To solve problem 1: redesign your database to take the serial number out of the PK.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic