CREATE OR REPLACE FUNCTION XXCHR_UPDATE (
P_SALESREP_ID IN NUMBER,
p_COLUMN_NAME IN VARCHAR2,
P_COLUMN_VALUE IN varchar2
)
RETURN VARCHAR2
IS
lv_dyn_sql VARCHAR2(2000):= NULL;
BEGIN
lv_dyn_sql := 'UPDATE thirty_days
SET attribute86 ='||p_COLUMN_NAME||',attribute87 ='||P_COLUMN_VALUE
|| 'WHERE SALESREP_ID = :1';
EXECUTE IMMEDIATE lv_dyn_sql using P_SALESREP_ID;
return(1);
EXCEPTION
WHEN OTHERS
THEN
dbms_output.put_line('Returning Error : '||SQLERRM);
--lv_return_val:= 0;
RETURN SQLERRM;
END XXCHR_UPDATE;
当我执行此函数时,返回错误
ORA-14551
请在这里建议
答案 0 :(得分:0)
尝试修改你的陈述:
lv_dyn_sql := 'UPDATE thirty_days
SET attribute86 ='||p_COLUMN_NAME||',attribute87 ='||P_COLUMN_VALUE
|| 'WHERE SALESREP_ID = :1';
到
lv_dyn_sql := 'UPDATE thirty_days
SET attribute86 ='||p_COLUMN_NAME||',attribute87 ='||P_COLUMN_VALUE
|| 'WHERE SALESREP_ID ='||P_SALESREP_ID;
当然:
EXECUTE IMMEDIATE lv_dyn_sql;
答案 1 :(得分:0)
为什么不是所有三个参数?摆脱字符串连接:
lv_dyn_sql := q'[UPDATE thirty_days
SET attribute86 = :arg1
, attribute87 = :arg2
WHERE SALESREP_ID = :arg3]';
execute immediate lv_dy_sql using p_column_name, p_column_value, p_salesrepid;