不知道我在做什麼錯誤。我嘗試了移動的東西,但沒有運氣。繼續收到以下錯誤。有人,請指教。Oracle中的PL/SQL錯誤
Declare
Begin
FOR v_rec IN (
select max(TotalEmployee) as TotalEmployee1 , Week_Day
from (select count(*) as TotalEmployee, TO_CHAR(hire_date, 'Day') as Week_Day
from Employee
group by TO_CHAR(hire_date, 'Day')
Order by TotalEmployee desc) Table1
group by Week_Day
)LOOP
dbms_output.put_line('*********************************************************************************************************************************************************************************************************');
dbms_output.put_line(v_rec.Week_Day || (v_rec.TotalEmployee1)||' employee');
dbms_output.put_line(rpad('Hire_Date', 15) || rpad('Name', 15) || rpad('JOB TITLE', 45) || rpad('SALARY', 20) || rpad('# of EMP',15) || rpad('DEPARTMENT NAME',20) ||rpad('MANAGER NAME',15) || rpad('MANAGER SALARY',15));
FOR v_rec1 IN (select HIRE_DATE , EMPLOYEE_NAME as Name , JOB_TITLE ,
Case when SALARY = null then '-------'
ELSE to_char(SALARY, '$9,999.99')
END as "SALARY" ,
Case when DEPARTMENT_NAME = null then '-------'
ELSE DEPARTMENT_NAME
END as DEPARTMENT_NAME,
Case when Employee_NAME = null then '-------'
ELSE Employee_NAME
END as MANAGERNAME,
Case when SALARY = null then '-------'
ELSE to_char(SALARY, '$9,999.99')
END as MANAGERSALARY
from Employee, department
where TO_CHAR(hire_date, 'Day') in (v_rec.Week_Day) and employee.DEPARTMENT_ID = department.DEPARTMENT_ID ) LOOP
dbms_output.put_line(rpad(v_rec1.HIRE_DATE, 15) || rpad(v_rec1.Name, 15) || rpad(v_rec1.JOB_TITLE, 45) || rpad(v_rec1.SALARY, 20) || rpad('# of EMP',15) || rpad(v_rec1.DEPARTMENT_NAME,20) ||rpad(Employee_NAME,15) || rpad(SALARY,15));
END LOOP;
END LOOP;
END;
不斷收到以下錯誤。有人請指教。
錯誤報告 -
ORA-06550: line 29, column 204:
PLS-00201: identifier 'EMPLOYEE_NAME' must be declared
ORA-06550: line 29, column 5:
PL/SQL: Statement ignored
06550. 00000 - "line %s, column %s:\n%s"
*Cause: Usually a PL/SQL compilation error.
*Action:
什麼是你的這個非常明確的錯誤消息,解釋'標識「EMPLOYEE_NAME」必須declared'? –
確認表中的列名並使用IS null而不是= null,因爲null不能與任何值進行比較。 – Shahzaib