rownum 可以控制行数 以及一个游标事例

来源:互联网 发布:抢楼软件 编辑:程序博客网 时间:2024/06/09 10:27

declare--- 声明

v_ename employees.last_name%type;

v_sal employees.salary% type;

cursor c_cursor is select last_name,salary from employees where DEPARTMENT_ID<100 and rownum<5;---定义游标

begin

open c_cursor;

fetch c_cursor into v_ename,v_sal;----提取游标内容

while c_cursor %found loop----为什么要%found

dbms_output.put_line(v_ename||'---'||to_char(v_sal));

fetch c_cursor into v_ename,v_sal;

end loop;

close c_cursor;

end;

原创粉丝点击