oracle - Comparing record type in pl/sql -
i have 2 tables like:
table 1 columns: prd_id, comp, td1, td2, td3
table 2 columns: acc_id, comp, td1, td2, td3
above account_id mapped prd_id
. want compare whether comp
, of values among td1
, td1
or td3
has been changed. give sample data.
table 1: prd_id comp td1 td2 td3 t y y y t b y n n table 2: acc_id comp td1 td2 td3 s n n y s b y n n
so, between above 2 tables, comp values have been changed. should count or values can use in if condition operation
if data stored in tables, don't need record type. can use minus
:
for in (select comp, td1, td2, td3 table1 minus select comp, td1, td2, td3 table2) loop -- changed records end loop;
if there no changes, code in cycle won't execute. code show rows table1
, differs rows in table2
. if need rows table2
, revert sql query:
for in (select comp, td1, td2, td3 table2 minus select comp, td1, td2, td3 table1) loop -- changed records end loop;
if want use explicit cursors:
declare cursor c1 select comp, td1, td2, td3 table1 minus select comp, td1, td2, td3 table2; c1_row c1%rowtype; begin open c1; loop fetch c1 c1_row; exit when c1%notfound; -- end loop; end;
Comments
Post a Comment