开始
SET SERVEROUTPUT ON; DECLARE v_empno emp.empno%TYPE; v_ename emp.ename%TYPE; CURSOR emp_cursor IS SELECT empno,ename from emp where empno<>1000; emp_record emp_cursor%ROWTYPE; BEGIN LOOP IF NOT emp_cursor%ISOPEN THEN OPEN emp_cursor; END IF; FETCH emp_cursor INTO emp_record; EXIT WHEN emp_cursor%NOTFOUND;
dbms_output.put_line
('rowcount is:'|| emp_cursor%ROWCOUNT || '-- empno is:' || emp_record.empno
|| '-- emp name is:' || emp_record.ename); END LOOP; END; /
这种 emp_record emp_cursor%ROWTYPE 的写法,比较方便。
结束