Hi All
I need to pass a column Name as an argument and use that in the select query of an update statement,How can i do that ?My update is using the merge statement like below
MERGE INTO RESULT RES
USING (select FIRST_NAME,EMPLOYEE_ID from EMPLOYEE) EMP
ON (RES.EID = EMP.EMPLOYEE_ID)
WHEN MATCHED THEN
UPDATE SET RES.DATA_VAL = EMP.FIRST_NAME
WHERE RES.EID = EMP.EMPLOYEE_ID
and RES.key=1;
the key and the attribute I have stored in another table like
below
KEY ATTR_NAME
1 FISRT_NAME
2 LAST_NAME
3 CITY
When I pass the key as an argument to the above script the select statement should change based on the corresponding attribute name in second table, ie if I pass key as 3 to the above script it should change to
MERGE INTO RESULT RES
USING (select CITY,EMPLOYEE_ID from EMPLOYEE) EMP
ON (RES.EID = EMP.EMPLOYEE_ID)
WHEN MATCHED THEN
UPDATE SET RES.DATA_VAL = EMP.CITY
WHERE RES.EID = EMP.EMPLOYEE_ID
and RES.key=3; (FIRST_NAME changed to CITY)
how can I do this ? I tried to use dynamic SQL but I am not able to use that in the select statement of an update statement please help me