• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

jdbc / prepared statement : only update values that have changed

 
Edmund Castermund
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am writing code that will handle edits to data existing in the db already. Basically what will happen is that html will be rendered by the request, and the user will hit an "edit" button. They will then be brought to a populated html form, they will make the changes they want (note that the form may have data that goes in several different tables, and the db tables and object structure do no match exactly). The updated data will be built into a json file and sent to the server. (the json file will indicate which fields have been updated, or alternatively only include those values that have been updated)

If I update all the fields in the row I can have sql stored in a text file. But if I only update the modified values, I then have to write code to build an appropriate sql statement. I know that keeping sql out of code is considered a best practice, and wondering if you guys have ever dealt with that particular scenario.

thanks!







 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't think I understand what exactly you're asking. For starters, what problem do you see in including all values in the update statement?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic