下面的函數編譯得很好。但是當以匿名的PL/SQL代碼調用函數時,調用失敗。 任何人都可以請建議爲什麼?我試圖插入未匹配(新)數據並更新匹配(現有)數據。調用失敗的函數:ORA-00904:「TEMP_DATA」。「P_LNAME」:無效標識符
Function Fn_Insert_Data_Using_Merge (p_Id in Number,
p_fname in varchar2,
p_mname in varchar2,
p_lname in varchar2,
p_birth_date in date) Return Boolean
Is
Begin
Dbms_Output.put_line ('Inside the function Fn_Insert_Data_Using_Merge ...');
Merge Into test_employee te
using (select distinct p_Id, p_fname, p_mname, p_lname, p_birth_date
from test_employee) temp_data
on (te.first_name = temp_data.p_fname and
te.middle_name = temp_data.p_mname and
te.last_name = temp_data.p_lname)
when matched then
update
set first_name = p_fname,
middle_name = p_mname,
last_name = p_lname,
run_status = 'Updated'
when not matched then
insert (id, first_name, middle_name, last_name, birth_date, run_status)
values
(p_id, p_fname, p_mname, p_lname, p_birth_date, 'Inserted');
Dbms_Output.put_line ('Returning successfully from the function Fn_Insert_Data_Using_Merge ...');
Return True;
Exception
When Dup_Val_On_Index Then
Dbms_Output.put_line ('The name already exists...Cannot insert again ..');
Return False;
When Others Then
Dbms_Output.put_line ('Facing some critical error : ' || SQLERRM);
Return False;
End Fn_Insert_Data_Using_Merge;
錯誤的行號是什麼? – Rachcha 2013-03-20 05:16:04
(te.first_name = temp_data.p_fname和te.middle_name = temp_data.p_mname和te.last_name = temp_data.p_lname) – 2013-03-20 05:41:27
ORA-06512:在「FC113EXT.PKG_TEST」,第101行 ORA-00904:「TEMP_DATA」。「 P_LNAME「:無效標識符 第101行是」合併到test_employee te「語句.. – 2013-03-20 05:49:59