PLSQL编程,常见错误总结

1、FOR循环下,不需要显示关闭游标

DECLARE
        CURSOR c_emp_cursor
        (
                deptno NUMBER
        )
        IS
                SELECT employee_id,last_name FROM employees WHERE department_id = deptno;

        r c_emp_cursor%ROWTYPE;
BEGIN
        FOR i IN c_emp_cursor(10)
        LOOP
                DBMS_OUTPUT.PUT_LINE(i.employee_id || '->'  || i.last_name);
        END LOOP;

        CLOSE c_emp_cursor;
END;
/
SQL> @tem.sql
200->Whalen
DECLARE
*
ERROR at line 1:
ORA-01001: invalid cursor
ORA-06512: at line 16

 

posted @ 2013-04-21 13:58  ArcerZhang  阅读(388)  评论(0编辑  收藏  举报