Had a case which need to use daynamic SQL and execute immediate statement. Share and memo a solution.
Customer's Needs:
There're two tables, A and B.
1. Update some columns in table B
2. The name of columns which will be updated are saved in table A(colname)
3. The columns' new value are saved in table A(colvalue)
4. Before get data from table A, we don't know which column will be updated.
Method:
1. Get data from table A and put in an cursor.
2. Create a dynamic SQL
3. Execute dynamic SQL
Code: