|
declare
-- カーソル定義
cursor c_depts is select dept_id,dept_name from dept;
-- SELECTで取得したレコードを代入する変数の定義
dept_rec c_depts%rowtype;
begin
open c_depts;
loop
-- フェッチ時に、取得項目を変数に代入。
fetch c_depts into dept_rec;
-- レコードが無くなればループ終了
exit when c_depts%notfound;
dbms_output.put_line('部門コード1:' || dept_rec.dept_id);
dbms_output.put_line('部門名称:' || dept_rec.dept_name);
end loop;
close c_depts;
end;
|