分類  >  資料庫 >

cursor variable 範例

tags:    時間:2013-12-23 21:49:16
cursor variable 實例
 create or replace procedure proc_test01 as  type emp_row is record( empno emp.empno%type, ename emp.ename%type, job emp.job%type, mgr emp.mgr%type, hiberdate emp.hiredate%type, sal emp.sal%type, comm emp.comm%type, deptno emp.deptno%type ); tmp0 emp_row; type cur_type is ref cursor; cur0 cur_type; BEGIN      open cur0 for select * from emp where rownum < 10;      loop       fetch cur0 into tmp0;      dbms_output.put_line(tmp0.job||',姓名:'||tmp0.ename||',工資:'||tmp0.sal);      exit when cur0%notfound;      end loop;      close cur0; END; 

在cmd命令窗口中執行:
SQL> set serveroutput on;
SQL> exec proc_test01;

推薦閱讀文章

Bookmark the permalink ,來源:互聯網