If you create your table with the ROWDEPENDENCIES
clause you can use the ORA_ROWSCN
pseudo-column to identify changed rows.
Here is a table
SQL> create table t23
2 (name varchar2(10)
3 , id number
4 ) rowdependencies
5 /
Table created.
SQL> insert into t23 values ('SAM-I-AM', 1)
2 /
1 row created.
SQL> insert into t23 values ('KNOX', 2)
2 /
1 row created.
SQL> insert into t23 values ('FOX', 3)
2 /
1 row created.
SQL> insert into t23 values ('LORAX', 9)
2 /
1 row created.
SQL> select ora_rowscn, id, rowid from t23
2 /
ORA_ROWSCN ID ROWID
---------- ---------- ------------------
1 AAB72FAAEAAA+4cAAA
2 AAB72FAAEAAA+4cAAB
3 AAB72FAAEAAA+4cAAC
9 AAB72FAAEAAA+4cAAD
SQL> commit
2 /
Commit complete.
SQL> select ora_rowscn, id, rowid from t23
2 /
ORA_ROWSCN ID ROWID
---------- ---------- ------------------
75288125 1 AAB72FAAEAAA+4cAAA
75288125 2 AAB72FAAEAAA+4cAAB
75288125 3 AAB72FAAEAAA+4cAAC
75288125 9 AAB72FAAEAAA+4cAAD
SQL>
Not the need to commit to get the Row SCN. Now let us make soem further changes and use the ORA_ROWSCN to spot which rows have changed...
SQL> update t23
2 set name = 'MR KNOX'
3 where id = 2
4 /
1 row updated.
SQL> insert into t23 values ('SALLY', 6)
2 /
1 row created.
SQL> commit;
Commit complete.
SQL> select ora_rowscn, id, rowid from t23
2 where ora_rowscn > 75288125
3 /
ORA_ROWSCN ID ROWID
---------- ---------- ------------------
75288182 2 AAB72FAAEAAA+4cAAB
75288182 6 AAB72FAAEAAA+4cAAE
SQL>
ORA_ROWSCN
was introduced in 10g. Find out more.
You will need a job to poll the table for changes. Also you need to build a table
in which the polling job can use to store the max(ora_rowscn)
for each run.