カーソル(特にOracleカーソル)に関する簡単な質問。
IDと名前の2つの列を持つ「my_table」というテーブルがあるとします。何百万もの行がありますが、名前の列は常に文字列「test」です。
次に、次のPL/SQLスクリプトを実行します。
declare
cursor cur is
select t.id, t.name
from my_table t
order by 1;
begin
for cur_row in cur loop
if (cur_row.name = 'test') then
dbms_output.put_line('everything is fine!');
else
dbms_output.put_line('error error error!!!!!');
exit;
end if;
end loop;
end;
/
これを実行しているときに、次のSQLを実行します。
update my_table
set name = 'error'
where id = <max id>;
commit;
PL / SQLブロックのカーソルはその変更を検出し、「エラー・エラー・エラー」を出力して終了しますか?または、変更をまったく取得しません...またはmy_tableの更新を許可しますか?
ありがとう!