MIDRANGE dot COM Mailing List Archive



Home » MIDRANGE-L » June 2014

Re: DB2 Auto-update TimeStamp



fixed

I seem to recall hearing that the DB was smart enough to not do an update
if nothing actually changed.

Though there appears to be some caveats to that. I tested a table with a
row change timestamp and the TS was changed. I'd assume that a
before/after update trigger would also force the DB to make the change.

Note I've seen the "no change update" in old code to release the lock on
the record. Either READ(N) wasn't available originally or the developer
didn't know about it.

Charles


On Wed, Jun 11, 2014 at 10:13 AM, Vernon Hamberg <vhamberg@xxxxxxxxxxxxxxx>
wrote:

Matt

I can imagine a scenario when a program does an update, and there might
not be a real change - do you check in your program for that, for every
possibility? Yes, there are ways to simplify that, but it might not be
something you want to code.

So it may or may not be bad coding practice - it depends, IMO.

Cheers
Vern


On 6/11/2014 9:09 AM, Matt Olson wrote:

Why are you issuing an update on a database table when no updates have
occurred? That is terrible programming practice.

-----Original Message-----
From: Ricky Thompson [mailto:rickyt29@xxxxxxxxx]
Sent: Wednesday, June 11, 2014 8:11 AM
To: midrange-l@xxxxxxxxxxxx
Subject: DB2 Auto-update TimeStamp

I know you can add a timestamp to a table that automatically updates on
insert and update. But can you have it only update if there is a real
change in the data? For example if a update is done to the table but no
data changes I would like for it not to update the timestamp. My guess is
no it's not possible but thought I would ask.


myTimeStamp TIMESTAMP NOT NULL GENERATED BY DEFAULT FOR EACH ROW ON
UPDATE AS ROW CHANGE TIMESTAMP
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing
list To post a message email: MIDRANGE-L@xxxxxxxxxxxx To subscribe,
unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx Before posting, please take a
moment to review the archives at http://archive.midrange.com/midrange-l.



--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list
To post a message email: MIDRANGE-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/midrange-l.







Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2014 by MIDRANGE dot COM and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available here. If you have questions about this, please contact