Search code examples
javatimestampsap-aseapache-metamodel

how to restore `timestamp` value in Sybase ASE 15.5?


I am reading data from one Table of Sybase ASE 15.5 database and inserting that data back into another target Sybase ASE 15.5 database. All source and destination data matched instead of timestamp column.

As what I know about the timestamp column is that it updates automatically:

Every time a row containing a timestamp column is inserted or updated, the timestamp column is automatically updated. A table can have only one column of the timestamp datatype. A column named timestamp will automatically have the system datatype timestamp.

Source: https://www.aquaclusters.com/app/home/project/public/aquadatastudio/wikibook/Sybase-ASE-3/page/4/Data-Types

Therefore, when I am restoring that timestamp data back into target database it does not match with the actual one.

Here is the screen short to Source Table

enter image description here

Here is the screen short to Destination Table

enter image description here

How to restore the exact value of timestamp column?

FYI:

I am using Apache Meta-model to query data from source table and restore that data back into the target database. As you can see timestamp is an array of bytes so I am extracting data as an array of bytes and restore it again as array of bytes but the value timestamp column is being changed when restore.


Solution

  • You can't. A timestamp column will always be updated; this value these columns contain is the 'database timestamp', which is at the basis of the transaction mechanism in ASE, and is incremented for every inserted or updated row or any other change in the database. The name 'timestamp' is misleading however, since it has absolutely nothing to do with real-world time. It's just a 6-byte counter that will only increase over the lifetime of the database.

    If you wanted a real-world time in those columns, use datatype 'datetime' or 'bigdatetime' instead.