• 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

how to update only the modified field values

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi friends,

I want to update only the modified field values in the database and not the values which are not modified .How to identify the fields which are modified ?
 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
your request is not clear, could you tell which field you say modified and wich field you say not modified (against to what constraint)
 
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As you are asking this in a Java forum, I assume you have a Java program that reads from a database, allows the user to change the values and then saves the data back to the database. Without more details of your program it is difficult to give you more than general advice such as you will need to have flags of some sort that indicate whether the data has been changed or not and then only save data when these flags indicate that it has changed.
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Since this is not an advanced question and has something to do with databases I'm moving it to the JDBC forum.
 
Ranch Hand
Posts: 502
jQuery Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Even you are updating only the modified column or all the column, you are going to execute an SQL. so it doesn't matter at all.

I guess, you need to do some heavy task for each column before it goes to database? is it so? can you explain us bit about your requirement?
 
meenu teenu
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

In my application i have a java program to display more than 300 fields in the screen.If i update all the fields the system speed becomes slow so what i want is to identify the fields whose values are modified and update those modified fields alone to the database.

Kindly Please help me to solve this
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So what is exactly the question, please be more specific. Identifying which fields have changed shouldn't be too difficult - you'll have to save the original values somewhere at the beginning, and when the time comes to update the data in the database, you compare the current values with what you had before. If the value is different, then you obviously have to update it in the database.

If you want a more specific answer, then post a more specific question. What exactly is your program doing now (post some code if necessary) and which part of it exactly runs slowly?
 
Prabhu Venkatachalam
Ranch Hand
Posts: 502
jQuery Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is 300 fields belongs to same table?
 
meenu teenu
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No, 300 fields belongs to different tables
 
Prabhu Venkatachalam
Ranch Hand
Posts: 502
jQuery Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So, the question is you want identify which table query to execute on update accroding to field which are modified?

Simple Solution is,

For JSP/Servlet application,

1. Have a hidden field for each of these fields in JSP

2. Check this hidden field value(old value) with the current value in your servlet or Action class, if it is different then you execute the query which belongs only to that table.

For Desktop application,

1. Have class which stores the old value of those fields.

2. each time when it reaches DB update, check the current value with previous value, if it is different then execute that particular query.


hth,
[ December 08, 2006: Message edited by: Prabhu venkatachalam ]
 
Politics n. Poly "many" + ticks "blood sucking insects". Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic