UPDATE P_ATTR
SET XC=ATTR_VAL,
SYS_MODIFIED_BY =UPPER(TRIM(USER_ID)),
SYS_MODIFIED_DATE =SYSDATE
WHERE ID_1 IN (SELECT ID_1
FROM EMP_MSTR
WHERE UPPER(x_SQL)= UPPER(LOC)
AND UPPER(LOC_CD)=UPPER('IND'));
获取错误消息:
PL / SQL:ORA-00904:“ XC”:无效的标识符
答案 0 :(得分:0)
否,没有动态SQL是不可能的。但是,您可以编写静态update语句来解释变量的值并更新正确的列。像这样:
(假设“ XC”是一个PL / SQL变量。如果您不在PL / SQL中,则将需要一个绑定变量,因此将每个出现的“ XC”替换为“:XC”。与“ ATTR_VAL”相同“。)
UPDATE P_ATTR
SET
COLUMN_1 = DECODE(XC,'COLUMN_1',ATTR_VAL,COLUMN_1),
COLUMN_2 = DECODE(XC,'COLUMN_2',ATTR_VAL,COLUMN_2),
COLUMN_3 = DECODE(XC,'COLUMN_3',ATTR_VAL,COLUMN_3),
COLUMN_4 = DECODE(XC,'COLUMN_4',ATTR_VAL,COLUMN_4),
...
SYS_MODIFIED_BY =UPPER(TRIM(USER_ID)),
SYS_MODIFIED_DATE =SYSDATE
WHERE ID_1 IN( SELECT ID_1
FROM EMP_MSTR
WHERE UPPER(x_SQL)= UPPER(LOC)
AND UPPER(LOC_CD)=UPPER('IND'));