码迷,mamicode.com
首页 > 数据库 > 详细

ORACLE fetch bulk collect into limit

时间:2016-07-20 17:32:53      阅读:226      评论:0      收藏:0      [点我收藏+]

标签:

DECLARE
  TYPE rr IS REF CURSOR;
  TYPE r_emp IS RECORD(
    empno    NUMBER(4),
    ename    VARCHAR2(10),
    job      VARCHAR2(9),
    mgr      NUMBER(4),
    hiredate DATE,
    sal      NUMBER(7, 2),
    comm     NUMBER(7, 2),
    deptno   NUMBER(2));
  TYPE t_e IS TABLE OF r_emp;
  e t_e;
  ee t_e:= t_e();
  r rr;
BEGIN
  OPEN r FOR
    SELECT * FROM apps.emp;
  LOOP
    EXIT WHEN r%notfound;--写在FETCH后面会掉数据
    FETCH r BULK COLLECT
      INTO e LIMIT 5;
    ee := ee multiset union e;
  END LOOP;
  for i in 1..ee.count loop
    dbms_output.put_line(ee(i).empno);
  end loop;
END;

 

ORACLE fetch bulk collect into limit

标签:

原文地址:http://www.cnblogs.com/wolil/p/5688929.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!