Home » SQL & PL/SQL » SQL & PL/SQL » Prevent update on field value if no changes
Prevent update on field value if no changes [message #284845] Sat, 01 December 2007 14:14 Go to next message
kensington
Messages: 2
Registered: December 2007
Junior Member
I need to check if an update on an Oracle 9i field value is a duplicate of what is already there.

If there is nothing there or if there is data there I need to make sure the record is not updated if nothing has been changed.

For example the field (called infoField) value has this in it:
id           infoField
34           Here is the current information.


The update form input infoField value (located in a JSP) will show the current database value for id = 34:
Here is the current information.

The database should not allow an update on the record if the user tries to update and didnt change or update the infoField value in the database.

Are there any contraints or a good way to do this??

[Updated on: Sat, 01 December 2007 14:43]

Report message to a moderator

Re: Prevent update on field value if no changes [message #284846 is a reply to message #284845] Sat, 01 December 2007 14:45 Go to previous messageGo to next message
Michel Cadot
Messages: 64106
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Why not just check it in your application and not execute the update statement? This is the good way.
Otherwise, you could add a (expensive) trigger to check if old and new fields are identical and then raise an error.

Regards
Michel

Re: Prevent update on field value if no changes [message #284847 is a reply to message #284846] Sat, 01 December 2007 14:51 Go to previous messageGo to next message
kensington
Messages: 2
Registered: December 2007
Junior Member
Thanks for your reply.

In the past I checked it using JSP/Servlets and always wondered if doing in the database would be easier or more efficient.

[Updated on: Sat, 01 December 2007 14:52]

Report message to a moderator

Re: Prevent update on field value if no changes [message #284848 is a reply to message #284847] Sat, 01 December 2007 15:36 Go to previous message
Michel Cadot
Messages: 64106
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
It is more efficient in the application, you then avoid network roundtrips and database work.

Regards
Michel
Previous Topic: triger
Next Topic: replacing/removing characters from strings (merged similar topics from same user)
Goto Forum:
  


Current Time: Mon Dec 05 02:45:18 CST 2016

Total time taken to generate the page: 0.16311 seconds