For Loop on item:'TELLER'不是光标

时间:2015-08-28 07:39:55

标签: plsql plsqldeveloper

我有以下光标:

FUNCTION managers_meerdere_depart RETURN t_managers_table_type AS
    CURSOR manager_ids IS SELECT manager_id, count(manager_id) AS teller FROM departments
    WHERE manager_id IS NOT NULL
    GROUP BY manager_id;

当我尝试迭代柜台(出纳员)时,

    FOR i IN teller LOOP <----- 
      SELECT d.department_id
      INTO v_dep_id
      FROM EMPLOYEES e
      JOIN DEPARTMENTS d ON e.employee_id = d.manager_id
      WHERE employee_id = manager_id_rec.manager_id;
      v_dep_ids(i) := v_dep_id;  
    END LOOP;

它给了我以下错误:

  

错误(84,33):PLS-00456:项目'TELLER'不是光标

1 个答案:

答案 0 :(得分:0)

你不应该使用出纳员代替柜台:

FOR manager_id_rec IN manager_ids LOOP IF (manager_id_rec.teller> 1) THEN SELECT first_name, last_name INTO v_first_name, v_last_name FROM employees WHERE employee_id = manager_id_rec.manager_id;

因为您为count(manager_id)提供了teller

的别名