Focal Point
[CLOSED] DB2 Advice Required -- Row Change Timestamp

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/6647053036

April 22, 2013, 03:20 PM
John_Edwards
[CLOSED] DB2 Advice Required -- Row Change Timestamp
I have a unique record extraction requirement where I need to pull records that have changed recently but that don't have an explicit timestamp in the table's fields. I've stumbled across a couple of threads on the Internet that say things on the line of

quote:

if you use DB2 v9 or later, you can use row change timestamp even if you didn't have the timestamp column

SELECT 1 FROM T1 WHERE ROW CHANGE TIMESTAMP FOR TAB t1 > current timestamp - 1 hours;


Is there anyone in WebFOCUS/Data Migrator land that has coded to this kind of concept that can help me with some of the basics? I'd be much obliged.

J.

This message has been edited. Last edited by: <Kathryn Henning>,



April 23, 2013, 05:02 AM
Martin vK
Dear John,
The idea seems very appealing to me, so although I have not used it, I tried to work with it and found out in our DB2 V9.5 it is not working as you suggest.
According to the IBM DB2 manual you indeed do need a timestamp column on the table defined with CREATE/ALTER table defined as GENERATED FOR EACH ROW ON UPDATE AS ROW CHANGE TIMESTAMP.
It seems it will become an implicitly hidden column, therefor it seems the table does not have the timestamp, but apparantly it should have been defined in this way to be used in your SELECT statement.

As stated, I did not know about this DB2 feature, and it might be different in other version than our V9.5 (LUW), but this is what I found in the DB2 manual.


WebFocus 8206M, iWay DataMigrator, Windows, DB2 Windows V10.5, MS SQL Server, Azure SQL, Hyperstage, ReportCaster
April 23, 2013, 05:39 AM
Wep5622
It looks like DB2 is an MVCC family database, so it's possible that you could get the information you want from something akin to a transaction id for the records. In general, the higher the transaction id the more recent the row.

Whether that helps depends on what you consider "changed" though. Inserted and updated records will be visible to your current transaction (if committed, of course) and you might be able to obtain the id of the transaction they originated from. Deleted (committed) records however won't be visible to your transaction.

I'm not sure this applies to DB2, but it's worth a shot.

You might want to mention what version and flavour of DB2 we're talking about here Wink

Edit: Google says: http://www.ibm.com/developerwo...icle/dm-0505stolze2/


WebFOCUS 8.1.03, Windows 7-64/2008-64, IBM DB2/400, Oracle 11g & RDB, MS SQL-Server 2005, SAP, PostgreSQL 11, Output: HTML, PDF, Excel 2010
: Member of User Group Benelux :
April 23, 2013, 11:13 AM
Clif
It appears that DB2 support of ROW CHANGE TIMESTAMP varies with platform (z/OS, Linux, Windows) and release (9.1, 9.2, etc.) so check that the expression works through the native DB2 client.

In the current Release 7.7.05 you can enclose DB2 dialect specific syntax in DB_EXPR(...) or you can create a synonym for an external SQL script and use that as a source.

In any DataMigrator release with a DBMS SQL Flow you can use any valid DB2 SQL expression that returns a result.


N/A
May 22, 2013, 10:40 AM
John_Edwards
quote:
DB_EXPR(


I'm on 7.7.04D and that function isn't available to me. It's a nice idea though, looking forward to it someday.

Thanks for the response. I have a similar post on the I-Way forums and maybe someone knows another way to skin the cat.

J.