欢迎投稿

今日深度:

PL SQL 带参数的游标的定义与应用,pl游标

PL SQL 带参数的游标的定义与应用,pl游标


CURSOR cursor_name(parameter_name datatype) IS select_statement; --只能制定类型,不能指定具体大小
OPEN cursor_name(参数值);
FECTH cursor_name INTO variable,...;

CLOSE cursor_name;

  1. declare   
  2. cursor emp_cursor(v_depnto number) is select ename,sal from scott.emp where deptno = v_depnto order by empno;  
  3. emp_record emp_cursor%rowtype;  
  4. v_dno number;  
  5. begin  
  6. v_dno := &no;  
  7. if not emp_cursor%isopen then  
  8.       open emp_cursor(v_dno);  
  9. end if;   
  10. null;  
  11. loop  
  12.         fetch emp_cursor into emp_record;   
  13.         exit when emp_cursor%notfound;  
  14.         dbms_output.put_line('姓名:'||emp_record.ename||',工资:'||emp_record.sal);  
  15. end loop;  
  16. null;  
  17. if emp_cursor%isopen then  
  18.        close emp_cursor;  
  19. end if;  
  20. end

www.htsjk.Com true http://www.htsjk.com/shujukunews/7172.html NewsArticle PL SQL 带参数的游标的定义与应用,pl游标 CURSOR cursor_name(parameter_name datatype) IS select_statement; --只能制定类型,不能指定具体大小 OPEN cursor_name(参数); FECTH cursor_name INTO variable,...; CLOSE cur...
评论暂时关闭