游标
游标类型:隐式游标,显示游标
游标有一些属性,例如SQL%ROWCOUNT返回被更新的数据行数
例子
SET SERVEROUTPUT ON
BEGIN
UPDATE emp SET COMM='100' WHERE empno='7369' FROM emp;
DBMS_OUTPUT.PUT_LINE('影响的行数为:'||SQL%ROWCOUNT);
END;
DECLARE
cursor c_emp is select * from emp;
vr_emp c_emp%rowtype;
v_count number := 0;
BEGIN
OPEN c_emp;
LOOP
FETCH c_emp INTO vr_emp;
v_count := v_count + 1;
EXIT WHEN c_emp%NOTFOUND;
DBMS_OUTPUT.PUT_LINE(v_count|| '--'||vr_emp.ename);
END LOOP;
CLOSE c_emp;
END;