指引网

当前位置: 主页 > 数据库 > SQLServer >

PLSQL带参数的游标的定义与应用

来源:网络 作者:佚名 点击: 时间:2018-03-14 17:54
[摘要] CURSOR cursor_name(parameter_name datatype) IS select_statement; --只能制定类型,不能指定具体大小OPEN cursor_name(参数 20540;);FECTH cursor_name INTO variable, ;CLOSE cursor_name;
CURSOR cursor_name(parameter_name datatype) IS select_statement; --只能制定类型,不能指定具体大小
OPEN cursor_name(参数值);
FECTH cursor_name INTO variable,...;
CLOSE cursor_name;


declare cursor emp_cursor(v_depnto number) is select ename,sal from scott.emp where deptno = v_depnto order by empno;
emp_record emp_cursor%rowtype; v_dno number;
begin v_dno := &no;
if not emp_cursor%isopen then open emp_cursor(v_dno);
end if; null;
loop fetch emp_cursor into emp_record;
exit when emp_cursor%notfound; dbms_output.put_line('姓名:'||emp_record.ename||',工资:'||emp_record.sal);
end loop; null;
if emp_cursor%isopen then close emp_cursor;
end if; end;

 


------分隔线----------------------------