<샘플코드에서 사용한 데이터는 HR 스키마이고, 오라클 설치시 생성할 수 있는 기본 스키마 입니다>
# using c_emp%notfound, c_emp%isopen,c_emp%rowcount
DECLARE
CURSOR c_emp is
SELECT employee_id,first_name FROM employees order by employee_id;
v_empno employees.employee_id%type;
v_first_name employees.first_name%type;
BEGIN
if c_emp%isopen then
null;
else
open c_emp;
end if;
dbms_output.put_line('the counter for cursor now is '||c_emp%rowcount);
loop
fetch c_emp into v_empno, v_first_name;
exit when c_emp%notfound or c_emp%rowcount>10 ;
dbms_output.put_line(c_emp%rowcount||' '||v_empno||' '||v_first_name);
end loop;
dbms_output.put_line('the counter for cursor now is '||c_emp%rowcount);
close c_emp;
END;
---------------------------
the counter for cursor now is 0
1 100 Steven
2 101 Neena
3 102 Lex
4 103 Alexander
5 104 Bruce
6 105 David
7 106 Valli
8 107 Diana
9 108 Nancy
10 109 Daniel
the counter for cursor now is 11
'Database > PLSQL' 카테고리의 다른 글
024 - [Oracle PL/SQL] Cursor - Cursor with Parameters (0) | 2024.02.20 |
---|---|
023 - [Oracle PL/SQL] Cursor - For loop cursor (0) | 2024.02.20 |
021 - [Oracle PL/SQL] Cursor - Explicit Cursor (0) | 2024.02.19 |
020 - [Oracle PL/SQL] Collections - Varray (0) | 2024.02.14 |
019 - [Oracle PL/SQL] Collections - Nested tables (0) | 2024.02.14 |