在 Oracle ADF 中显示经理名称而不是经理 ID

Display Manager name instead of Manager Id in Oracle ADF

员工 table 包含 -

 Employee_Id,
 Manager_Id,
 First_Name,
 Last_Name

我想显示经理姓名而不是 id

无法使用LOV

VO 中的当前查询:

   SELECT 
      Employees.EMPLOYEE_ID, 
      Employees.FIRST_NAME, 
      Employees.LAST_NAME, 
      JobObject.JOB_TITLE, 
      Employees.COMMISSION_PCT, 
      Departments.DEPARTMENT_NAME, 
      Departments.DEPARTMENT_ID, 
      JobObject.JOB_ID, 
      (First_Name||' '||Last_Name) AS VIEW_ATTR, 
      Employees.SALARY, 
      Employees.MANAGER_ID
 FROM EMPLOYEES Employees, 
      DEPARTMENTS Departments, 
      JOBS JobObject
WHERE Employees.DEPARTMENT_ID = Departments.DEPARTMENT_ID

如果我没理解错的话,你什么也得不到的原因与join有关,当你在FROM子句中使用逗号时,你可能会遇到问题。 对于 managername 如果你有一个经理 table 你必须内部加入那个或试试这个:

 SELECT Employees.EMPLOYEE_ID, 
   Employees.FIRST_NAME, 
   Employees.LAST_NAME, 
   JobObject.JOB_TITLE, 
   Employees.COMMISSION_PCT, 
   Departments.DEPARTMENT_NAME, 
   Departments.DEPARTMENT_ID, 
   JobObject.JOB_ID, 
   (Employees.First_Name+' '+Employees.Last_Name) AS ManagerName, 
   Employees.SALARY, 
   Employees.MANAGER_ID
   FROM EMPLOYEES Employees,
inner join
 DEPARTMENTS Departments on Employees.DEPARTMENT_ID = Departments.DEPARTMENT_ID
 left outer join 
JOBS JobObject on JobObject.Job_Id=Employees.Job_Id
where Employees.MANAGER_ID is not null and Employees.MANAGER_ID in (EMPLOYEE_ID from employees)

我假设您想显示经理姓名和员工详细信息。是的话下面的查询会有帮助。

  SELECT emp.EMPLOYEE_ID,
   emp.FIRST_NAME,
   emp.LAST_NAME,
   JobObject.JOB_TITLE,
   emp.COMMISSION_PCT,
   dept.DEPARTMENT_NAME,
   dept.DEPARTMENT_ID,
   JobObject.JOB_ID,
   (emp_manager.First_Name || ' ' || emp_manager.Last_Name) AS manager_name,
   emp.SALARY
 FROM EMPLOYEES emp
   JOIN DEPARTMENTS dept ON (emp.department_id = dept.department_id)
   JOIN JOBS JobObject ON (emp.job_id = JobObject.job_id)
   JOIN EMPLOYEES emp_manager ON( emp.manager_id = emp_manager.employee_id  )