當我在我的Oracle SQL Developer請調試以下Oracle SQL過程
create or replace
Procedure Table_Update
IS
s_id VARCHAR2(256 byte);
CURSOR C1 IS
SELECT A.SR_ID
FROM TABLE_2 B,TABLE_1 A
WHERE A.Primary_key=B.Primary_Key;
BEGIN
loop
open c1;
fetch c1 into s_id;
exit when C1%NOTFOUND ;
update TABLE_2 set SR_ID = s_id;
commit;
END LOOP;
CLOSE C1;
END;
運行下面的過程中TABLE_1和TABLE_2這裏有類似structure.My要求從TABLE_1 SR_ID應TABLE_2基礎上進行更新相匹配的主key.When我運行的程序,我得到了以下錯誤消息
Connecting to the database XXX.
ORA-06511: PL/SQL: CURSOR ALREADY OPEN
ORA-06512: at "Table_Update", line 7
ORA-06512: at "Table_Update", line 13
ORA-06512: at line 2
PROCESS EXITED.
Disconnecting from the database XXX.
我已經嘗試這種遍地請幫我
謝謝
我不是專家,但我認爲YOUE缺少'where'在'update'聲明條款。 – haki
另外一點,除了a_horse_with_no_name的優秀答案,如果你願意這樣做,即你有一個500米的行表,並且不能鎖定整個事物,那麼最好使用BULK COLLECT並更新ROWID要快得多。 – Ben