Compare two identical tables and to report only column values that has changed

  • Can someone please help on a Oracle PL/SQL code which will compare each column in 2 similar structured (similar data as well and one tend to change wherein I need to capture that change) oracle tables and to result in only row numbers, column name (which got updated), old value, new value. Like below.

    RNUM CNAME OLD_VAL NEW_VAL

    ------------ -------------------- ------------------------------ -----------------------------

    1 ENAME Name11 Name1

    1 HIREDATE 13-may-2011 13-may-2001

    3 ENAME Name32 Name3

    3 HIREDATE 13-jul-2011 13-jul-2001

    4 DESIGNATION SENIOR ANALYST ANALYST

    5 SALARY 10000 5000

    I do not want to hard code any column names in the code, it should be like a generic script i.e. if I input 2 table names then it should fetch its column names from metadata and then should perform the comparison. Thanks in advance.

  • kokilaeb (6/5/2016)


    Can someone please help on a Oracle PL/SQL code which will compare each column in 2 similar structured (similar data as well and one tend to change wherein I need to capture that change) oracle tables and to result in only row numbers, column name (which got updated), old value, new value. Like below.

    RNUM CNAME OLD_VAL NEW_VAL

    ------------ -------------------- ------------------------------ -----------------------------

    1 ENAME Name11 Name1

    1 HIREDATE 13-may-2011 13-may-2001

    3 ENAME Name32 Name3

    3 HIREDATE 13-jul-2011 13-jul-2001

    4 DESIGNATION SENIOR ANALYST ANALYST

    5 SALARY 10000 5000

    I do not want to hard code any column names in the code, it should be like a generic script i.e. if I input 2 table names then it should fetch its column names from metadata and then should perform the comparison. Thanks in advance.

    Have you considered posting your question in an Oracle forum, rather than SQL Server? You might get a better response:cool:

    If you haven't even tried to resolve your issue, please don't expect the hard-working volunteers here to waste their time providing links to answers which you could easily have found yourself.

  • There is no forum for oracle discussion.

  • kokilaeb (6/8/2016)


    There is no forum for oracle discussion.

    Really? So what is this?

    https://community.oracle.com/community/database/developer-tools/sql_and_pl_sql

    If you haven't even tried to resolve your issue, please don't expect the hard-working volunteers here to waste their time providing links to answers which you could easily have found yourself.

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply