SAS Enterprise Guide

Desktop productivity for business analysts and programmers
BookmarkSubscribeRSS Feed
alepage
Barite | Level 11

Hello,

I would like to know if someone has already developped a SAS scprit to estimate the last time an oracle table was updated.

Please provide an example.

Regards,

I have tried that in Toad:

SELECT (MAX(ora_rowscn)) from MRKT_???.QUALTRIX_??????;
The response is:

6479526695024 

select scn_to_timestamp(6479526695024) as timestamp from dual;

ora-08181; specific number is not a valid system change number
ora-06512 : at sys.scn_to_timestamp, line 1

How can I get the last updated date

2 REPLIES 2
SASKiwi
PROC Star

Googling the question provides this:

SELECT SCN_TO_TIMESTAMP(MAX(ora_rowscn)) from myTable;

Apparently this only works for 'recent' updates so taking the max value is important.

AhmedAl_Attar
Ammonite | Level 13

Hi @alepage 

Typically, such questions should be directed to your Oracle DBA. But here is what I was able to find on this page Using Oracle Flashback Technology

 

Using ORA_ROWSCN
ORA_ROWSCN is a pseudocolumn of any table that is not fixed or external. It represents the SCN of the most recent change to a given row; that is, the latest COMMIT operation for the row. For example:

SELECT ora_rowscn, last_name, salary
  FROM employees
  WHERE employee_id = 7788;

ORA_ROWSCN    NAME    SALARY
----------    ----    ------
    202553    Fudd      3000
The latest COMMIT operation for the row took place at approximately SCN 202553. To convert an SCN to the corresponding TIMESTAMP value, use the function SCN_TO_TIMESTAMP.

Hope this helps,

Ahmed

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

Register now!

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 3955 views
  • 1 like
  • 3 in conversation