Zsolt Botykai
Zsolt Botykai

Reputation: 51663

adding oracle's timestamp to query results

yesterday you had taught me to query record history within a time range here.

What more I need is to add oracle's (historical) timestamp to the results as a column. Is it possible?

Thanks in advance.

Upvotes: 1

Views: 1705

Answers (1)

Tony Andrews
Tony Andrews

Reputation: 132670

Yes, in fact the answer to your previous question shows how:

SQL> select empno, sal, versions_starttime,versions_xid
  2  from emp
  3  versions between timestamp sysdate-1 and sysdate
  4  where empno=7369;

     EMPNO        SAL VERSIONS_STARTTIME                                                          VERSIONS_XID
---------- ---------- --------------------------------------------------------------------------- --
      7369       5900 11-DEC-08 16.05.32                                                          0014001300002A74
      7369       5800 11-DEC-08 16.03.32                                                          000D002200012EB1
      7369       5800

There is also a VERSIONS_ENDTIME pseudo-column. Between them VERSIONS_STARTTIME and VERSIONS_ENDTIME bracket the period of time during which the change was made.

Upvotes: 2

Related Questions