游标、type使用示例


declare

  my_cur sys_refcursor; --定义游标变量

  type v_record is record( --定义 record类型
    obj_id   number,
    obj_name varchar2(2000));

  my_record v_record;   --定义record变量

begin
  open my_cur for 'select object_id,object_name from dba_objects where object_id <20';
  loop
    fetch my_cur
      into my_record;
    exit when my_cur%notfound;
    dbms_output.put_line(my_record.obj_id || chr(9) || my_record.obj_name);
  end loop;
end;

posted @ 2016-11-27 17:27  Oracle-fans  阅读(511)  评论(0编辑  收藏  举报