hi
I have 3 tables - table1,table2,table3
table1 has 3 columns named col1,col2 and col3 and has 1 dummy record with values 0,1,2 respectively. The other records are my master records
col1 col2 col3
0 1 2
A B C
AA BB C
D E F
table 2 has the mapping of the column as shown below
ColNo Name Descr Conditon
0 ABC BC Yes
1 DEF DE No
2 GHI GH Yes
Now i have to populate values in table 3 from table 2 and table 1
The logic is as follows
Suppose first i read col1 from table1. I look and take the value 0 (dummy value) and i check the in table 2 if for 0 the condition is Yes or No. If its No I ignore the col1 and move to col2. If not i start populating values of col1 first and then move to next col2.
In the above table shown above, since condition for 0 is Yes i read values for col1 (which will be A,AA,D) and from table 2 i read value for 0 (ABC,BC) and populate it in table3. Once all data is populated for col1, i move to col2. Since col2 condition is No in Table2, i ignore col2 and then i finally read col3 (the condition is Yes for col3 in Table2) and my table3 should look as follows
ColNo Typ Name Descr
0 A ABC BC
0 AA ABC BC
0 D ABC BC
2 C GHI GH
2 F GHI GH
This can be accomplished either using function or pl/sql procedure