How to loop in a cursor referencing column names in all_tab_columns

I have 2 identical tables with same columns.  I have to compare both to detect any changes made in both tables.  When a change is detected, I have to get the column name, the value from one table and the value of the other table.  I know I can use MINUS statement: select * from table A MINUS select * from table B, the results are rows with all records in table A which table B don't have.  That's great, but I still have to compare each value in each column and note the changes.  Both tables have 75 columns, it is time consuming to type each column name, so I want to use all_tab_columns to get all the column names.  My problem is, how to reference back to the column name in my cursor? Below is the code sample, I am stuck at:' if B.A.column_name != C.A.column_name then' statement.
If you know how to rewrite it or better way to do this, let me know please, I really appreciate any help.

declare
cursor columns_cur is
select column_name
from all_tab_columns
where table = 'FLO_1'
and owner = 'CIS'
order by column_id;

cursor flo_1_cur is
select * from flo_1;

cursor flo_2_cur(c_flo_id in number) is
select * from flo_2
where flo_id = c_flo_id;

t_column_name       varchar2(20);
t_value_changed_ind       varchar2(1);
t_old_value             varchar2(20);
t_new_value            varchar2(20);
begin
for A in columns_cur
loop
      for B in flo_1 cur
      loop
            for C in flo_2_cur(B.flo_id)
            loop      
                                                         if B.A.column_name != C.A.column_name then
                  t_column_name := A.column_name;
                  t_value_changed_ind  := 'Y';
                  t_old_value := B.A.column_name;
                  t_new_value := C.A.column_name;
                  else
                  t_value_changed_ind  := 'N';                              end if;
            end loop;
      end loop;
end loop;
end;
muliaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

HainKurtSr. System AnalystCommented:
u can use exec immediate... maybe it works... not sure now..

col_equal boolean;
exec immediate "col_equal := B." || A.column_name || "="C." || A.column_name || ";"
or
exec immediate "begin col_equal := B." || A.column_name || "="C." || A.column_name || "; end;"
then use col_equal

if col_equal then
...
else
...
end if
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
muliaAuthor Commented:
Thanks, not the exact answer I was looking for, but it gave me an idea to exec immediate select the old value into a variable and select the new value into a variable, then compare both variables.

0
mpasemCommented:
Have you figured out how to do it?
I need help in doing this too. I am thinking of spooling data from 2 tables into two different flat files and then do a diff on them.
since I have to modify one table to be like the other table.
but I have to use all_tab_columns to get the order of columns to spool into flat file.
select ( select column_name from all_tab_columns where table_name = 'x' order by column_id) from x;
something like this. Can you help me with that.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Oracle Database

From novice to tech pro — start learning today.