我想寫一個sql腳本,在Oracle中插入查詢,其中一個值將從光標中獲取,其餘所有將從表中檢索。用光標值插入到select查詢中
對於例如:考慮Employee表,
Emp_No | Emp_Name
1 | AAA
...........
我讀表入裏的光標。
Cursor c1 is select emp_no, emp_name from employee;
我正在迭代遊標並將其與另一個表中的信息一起添加到表中。
for empCur in c1
loop
insert into employee_info(emp_no, emp_name, address, age, ...) values (empCur.emp_no, empCur.emp_name, select t.address, t.age, ... from employee_temp_table t where t.emp_no=empCur.emp_no)
end loop;
我的腳本是否有效?如果沒有其他方法來實現它?由於很少有值在遊標中,而且很少有值在另一個表中,所以我不確定如何處理這些值,請幫助我。