Oracle(三)存储过程与游标
--创建或修改存储过程,存储过程名为findclass,输入参数为classId,输出className create or replace procedure findclass(classId in int,classStudents out sys_refcursor,className out varchar2) as --定义一个游标的方式有多种,可以显示定义CURSOR cursor_name is select * from table,也可以定义动态游标,游标关键词CURSOR TYPE ref_cursor_type IS REF CURSOR; --定义一个动态游标 students ref_cursor_type; --定义班级集合为一个游标类型 student_row student%rowtype; --定义班级类型,类型为student表行类型 --存储过程开始 begin --把查询出来的class_name 赋值给输出变量className,查询条件为classId select class_name into className from class where id = classId; --打开游标并赋值 open students for select * from student where fk_class =classId; -