我们可以动态声明游标或记录吗?
CURSOR employee_id_cur
IS
select * from <user entry table name>
类似记录。
答案 0 :(得分:0)
请参考以下示例:
DECLARE
TYPE EmpCurTyp IS REF CURSOR;
emp_cv EmpCurTyp;
emp_rec emp%ROWTYPE;
sql_stmt VARCHAR2(200);
my_job VARCHAR2(15) := 'CLERK';
BEGIN
sql_stmt := 'SELECT * FROM emp WHERE job = :j';
OPEN emp_cv FOR sql_stmt USING my_job;
LOOP
FETCH emp_cv INTO emp_rec;
EXIT WHEN emp_cv%NOTFOUND;
-- process record section.....
END LOOP;
CLOSE emp_cv;
END;
/