Hi
I would like to know how to generate a comparison between two tables, using only a few columns.
I explain according to the example e below
I have Table01 and Table02, both have the same number of columns, the same names and the same types,
but I can't compare all columns from the two tables, I must check in another table TBL_METADATA
which columns can I compare, for this I must check for the COMPARE column of the TBL_METADATA table
, if the COMPARE column is with Y I must compare, if it is with N, I must not compare.
TABLE1
NAME TYPE
ID NUMBER
COLUMN01 NUMBER
COLUMN02 NUMBER
COLUMN03 NUMBER
COLUMN04 NUMBER
COLUMN05 NUMBER
COLUMN06 NUMBER
COLUMN07 NUMBER
COLUMN08 NUMBER
COLUMN09 NUMBER
COLUMN10 NUMBER
COLUMN11 NUMBER
---------------------------------
TABLE2
NAME TYPE
ID NUMBER
COLUMN01 NUMBER
COLUMN02 NUMBER
COLUMN03 NUMBER
COLUMN04 NUMBER
COLUMN05 NUMBER
COLUMN06 NUMBER
COLUMN07 NUMBER
COLUMN08 NUMBER
COLUMN09 NUMBER
COLUMN10 NUMBER
COLUMN11 NUMBER
-------------------------------
TBL_METADATA
NAME COMPARE
COLUMN01 Y
COLUMN02 Y
COLUMN03 N
COLUMN04 Y
COLUMN05 N
COLUMN06 N
COLUMN07 N
COLUMN08 N
COLUMN09 N
COLUMN10 Y
COLUMN11 N
In this example, I used only 11 columns, but the tables can have more than 250 columns, I would like to
know how I can do this using dynamic sql, and if it is possible to do it without using dynamic sql
In this example the query would look something like
SELECT COLUMN01,COLUMN02,COLUMN04, COLUMN10 FROM TABLE01
MINUS
SELECT COLUMN01,COLUMN02,COLUMN04, COLUMN10 FROM TABLE02
Thank you in Advance