• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

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

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Marshal
Posts: 80093
413
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your suggestion .

what can i do for problem 1.
 
Campbell Ritchie
Marshal
Posts: 80093
413
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
To solve problem 1: redesign your database to take the serial number out of the PK.
 
Today you are you, that is turer than true. There is no one alive who is youer than you! - Seuss. Tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic