How do I exclude unchanged fields in Flashback query resultset?

All we need is an easy explanation of the problem, so here it is.

Is it possible to exclude unchanged fields in Flashback query resultset?

Consider I have following table

create table first_table
(
    id int generated as identity,
    name NVARCHAR2(1024),
    age smallint,
    notebook nclob,
    userpic clob,
    salary float
)

If the table has very frequent updates (e.g. on notebook field) following versioned query

select ROWID, VERSIONS_OPERATION, VERSIONS_STARTSCN, VERSIONS_STARTTIME, VERSIONS_XID, id, name, age, notebook, userpic, salary
from FIRST_TABLE versions between scn 1469193 and 1482882;

will pull heavy userpic value for every row even though it’s the same.

Can I somehow avoid that and instead get NULLs for unchanged values ?

How to solve :

I know you bored from this bug, So we are here to help you! Take a deep breath and look at the explanation of your problem. We have many solutions to this problem, But we recommend you to use the first method because it is tested & true method that will 100% work for you.

Method 1

Is there a way to excluded unchanged fields from versioned response?

Not really.

Flashback uses the information found in UNDO. Flashback Data Archive stores the results from the Log files in a table.

So, you get ALL of the data when you do a Flashback query.

The common method is to use LAG + DECODE. But, I’m afraid that this will problematic for your LOB columns.

Personally, I’d pawn off the problem to the UI (Display Tier).

Note: Use and implement method 1 because this method fully tested our system.
Thank you 🙂

All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply