declare 

temp SYS_REFCURSOR;

n  number;

begin 

 -- open sys_refcursor for select statement

open  temp for select level from dual connect by level < 4 ;


loop -- cursor is in open state , cursor attributes are applicable

  fetch temp  into n; -- fetch current record from temp assign to n 

    dbms_output.put_line('n'||n); 

  exit when temp%notfound;-- loop through the curesor until all the dataset exhausts

end loop;

  if  temp%found then 

    dbms_output.put_line('tempfound'||temp%rowcount);

  end if;

  

  if  temp%notfound then 

  dbms_output.put_line('tempnotfound'||temp%rowcount);

  end if;

 

  if  temp%isopen then 

  dbms_output.put_line('tempisopen'||temp%rowcount);

  end if;

  

  close temp;

  

end;

Comments

Popular posts from this blog