create or replace PROCEDURE PROC_STU3 AS
BEGIN
--显示游标使用,使用for循环
declare
--定义游标,名称为cur_stu
cursor cur_stu is
select stuno,stuname from student order by stuno;
begin
for stu in cur_stu
loop
dbms_output.PUT_LINE(stu.stuno||'->'||stu.stuname);
--循环做隐含检查 %notfound
end loop;
--自动关闭游标
end;
END PROC_STU3;
proc_1:
create or replace procedure proc_1 as
BEGIN
DECLARE
emp_id employees.employee_id%type;
CURSOR cur IS
SELECT b.employee_id, b.ROWID ROW_ID
FROM employees b
ORDER BY b.ROWID;
BEGIN
FOR row IN cur LOOP
DBMS_OUTPUT.PUT_LINE('last name: '||row.employee_id||'--'||row.ROW_ID);
END LOOP;
END;
end proc_1;
proc_2:
create or replace procedure proc_2 as
BEGIN
declare
cursor emp_cursor is select ename,sal from emp where deptno=10;--定义游标,指定游标所对应的
v_ename emp.ename%type; ---定义接收游标数据的变量
关闭游标
最新推荐文章于 2023-05-15 22:27:08 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)