Based on source1 & source2 data should be inserted / deleted in output tables. Initially these fields -fieldcd, field6cd,field7cd in ouptut tables will be inserted thru this code. Additionally, user will have an option to update these (fieldcd,field6cd,field7cd ) values thru UI.
In tables by dafault table1output-fieldcd=2;table2output-field6cd=2;table3output-field7cd=2 values will be inserted.
field1 is common in 3 output tables.
Conditions - scenario1 - when table1output=2 - If New row added or deleted existing row in source1 or source 2. - In this case, records should be inserted or delete in table2output and table3output when table1output-fieldcd=2. If any record is inserted or deleted in table2output corresponding values should be inserted or deleted in table3output
scenario2 - when table1output-fieldcd=3 - If New row added or deleted existing row in source1 or source 2. - In this case, records should be inserted or delete in table2output and table3output when table1output-fieldcd=3 and table2output-field6cd=2 and table3output-field7cd=2 only. If any record is inserted or deleted in table2output corresponding values should be inserted or deleted in table3output. If anyof the of the record table3output-field7cd<>2 then that asosciated values should be deleted from table2output
source1
field1 | field2 | field3 |
1 | 249 | 49 |
2 | 249 | 49 |
3 | 249 | 49 |
4 | 249 | 761 |
5 | 313 | 761 |
6 | 313 | 761 |
7 | 313 | 761 |
8 | 313 | 761 |
9 | 313 | 761 |
10 | 313 | 86 |
11 | 2518 | 86 |
12 | 2518 | 14 |
13 | 211 | 3 |
14 | 211 | 3 |
15 | 211 | 3 |
16 | 211 | 3 |
17 | 211 | 3 |
18 | 120 | 3 |
19 | 120 | 3 |
source2
field9 | field3 |
13863 | 49 |
13864 | 49 |
13865 | 49 |
13737 | 761 |
13738 | 761 |
13739 | 761 |
13740 | 761 |
13741 | 761 |
13742 | 761 |
12510 | 86 |
13595 | 86 |
10093 | 14 |
10439 | 3 |
10440 | 3 |
10441 | 3 |
10442 | 3 |
10444 | 3 |
10445 | 3 |
10447 | 3 |
table1output
field1 | field2 | fieldcd |
1 | 249 | 2 |
2 | 313 | 2 |
3 | 2518 | 1 |
4 | 211 | 3 |
5 | 120 | 1 |
table2output
field1 | field4 | field5 | field6cd |
1 | 1 | 49 | y |
1 | 2 | 49 | n |
1 | 3 | 49 | n |
1 | 4 | 761 | n |
2 | 5 | 761 | n |
2 | 6 | 761 | n |
2 | 7 | 761 | n |
2 | 8 | 761 | y |
2 | 9 | 761 | y |
2 | 10 | 86 | n |
3 | 11 | 86 | n |
3 | 12 | 14 | n |
4 | 13 | 3 | y |
4 | 14 | 3 | y |
4 | 15 | 3 | y |
4 | 16 | 3 | n |
4 | 17 | 3 | n |
5 | 18 | 3 | n |
5 | 19 | 3 | n |
table3output
field1 | field7cd | field7 | field8 |
1 | y | 1 | 13863 |
1 | n | 2 | 13864 |
1 | n | 3 | 13865 |
1 | n | 4 | 13737 |
2 | n | 5 | 13738 |
2 | n | 6 | 13739 |
2 | n | 7 | 13740 |
2 | y | 8 | 13741 |
2 | y | 9 | 13742 |
2 | n | 10 | 12510 |
3 | n | 11 | 13595 |
3 | n | 12 | 10093 |
4 | n | 13 | 10439 |
4 | n | 14 | 10440 |
4 | y | 15 | 10441 |
4 | y | 16 | 10442 |
4 | n | 17 | 10444 |
5 | n | 18 | 10445 |
5 | n | 19 | 10447 |