尝试将记录与游标一起使用,然后在混合中按表索引。
DECLARE CURSOR emp_cur IS
SELECT employee_id, first_name||' '|| last_name "name"
FROM employees
ORDER BY salary desc;
emp_rec emp_cur%ROWTYPE;
BEGIN
FOR emp_rec IN emp_cur
LOOP
DBMS_OUTPUT.PUT_LINE('Employee ID:'||emp_rec.employee_id||CHR(10)||
'Employee Name:'||emp_rec.name);
EXIT WHEN emp_cur%ROWCOUNT = 10;
END LOOP;
END;
当我运行上面的代码时,我得到
ERROR at line 13, "NAME" must be declared.
如何访问列 first_name||' '||for 循环内的last_name?还是我只需要进行传统的 OPEN、简单循环、FETCH 和关闭?