1.  
  2. SQL> create table product(
  3.   2     product_id number(4)     not null,
  4.   3     product_description varchar2(20) not null
  5.   4  );
  6.  
  7. Table created.
  8.  
  9. SQL>
  10. SQL> insert into product values (1,'Java');
  11.  
  12. 1 row created.
  13.  
  14. SQL> insert into product values (2,'Oracle');
  15.  
  16. 1 row created.
  17.  
  18. SQL> insert into product values (3,'C#');
  19.  
  20. 1 row created.
  21.  
  22. SQL> insert into product values (4,'Javascript');
  23.  
  24. 1 row created.
  25.  
  26. SQL> insert into product values (5,'Python');
  27.  
  28. 1 row created.
  29.  
  30. SQL>
  31. SQL>
  32. SQL> DECLARE
  33.   2    refCursorValue SYS_REFCURSOR;
  34.   3    myRecord product%ROWTYPE;
  35.   4  BEGIN
  36.   5    OPEN refCursorValue FOR SELECT *from product;
  37.   6
  38.   7    LOOP
  39.   8      FETCH refCursorValue INTO myRecord;
  40.   9      EXIT WHEN refCursorValue%NOTFOUND;
  41.  10      dbms_output.put_line(to_char(myRecord.product_id)||' '||
  42.  11      rpad(myRecord.product_description,20,' '));
  43.  12    END LOOP;
  44.  13    CLOSE refCursorValue;
  45.  14  END;
  46.  15  /
  47. 1 Java
  48. 2 Oracle
  49. 3 C#
  50. 4 Javascript
  51. 5 Python
  52.  
  53. PL/SQL procedure successfully completed.
  54.  
  55. SQL>
  56. SQL> drop table product;
  57.  
  58. Table dropped.

Kaynak : http://www.java2s.com/Tutorial/Oracle/0500__Cursor/AnexampleofusingSYSREFCURSORforcursorvariableprocessing.htm



*** *** KANALIMIZA ABONE OLMAYI UNNUTMAYIN ** ***

*** *** KANALIMIZA ABONE OLMAYI UNNUTMAYIN *** ***