I have a question regarding Oracle cursor.
I need to compare the values in a selected list of columns, see which records have changed after update. The table is huge, the only way to distinguish between new and old record is by the Batch_ID.
The output table will include these information:
So i have something very basic like below, except that i need to write like hundreds of SELECT statement in order to go through hundreds of columns.
SELECT a.*, b.LAST_name AS last_name_updated --- here the variable could be ethnicity, income category etc..
from (SELECT person_id, last_name
FROM person
WHERE batch_id = (select max(batch_id) from person)
) a FULL OUTER JOIN
(SELECT person_id, last_name
FROM person
WHERE batch_id = (select max(batch_id) - 1 from person)
) b
ON a.person_id = b.person_id
WHERE nvl(a.last_name,0) <> nvl(b.last_nm,0)
I need to go through a list of about 500 field name like Income, Race, Last_Name etc and capture all the changes, if any, in all these columns.
how do i go about this without writing hundreds of these SELECT statements?
Thanks in advance for your help!