Click here to Skip to main content
15,904,416 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I create function to sum days in my table and i want display this days for every employee in select query.

What I have tried:

this is the function :-
create or replace
FUNCTION "GETEMPLOYEE_MassionDays" (EMPLOYEE_ID_P NUMBER,month_P number,year_P number)
RETURN decimal 
  IS VALUE_P decimal;
BEGIN
SELECT SUM(TO_DATE(PROF_TASKS.TASK_END_DATE) - TO_DATE(PROF_TASKS.TASK_START_DATE) + 1) into VALUE_P FROM PROF_TASKS
where EMPLOYEE_ID=EMPLOYEE_ID_P 
and extract(month from TASK_START_DATE)=month_P
and extract(year from TASK_START_DATE)=year_P
order by TASK_START_DATE
;
RETURN VALUE_P;
END;


and this is select query :-

SELECT PROF_TASKS.EMP_CODE ,PROF_EMPLOYEE_DATA.EMP_NAME_AR ,PROF_TREE_DETAILS.TREE_NAME 
,nvl(GETEMPLOYEE_MassionDays(PROF_EMPLOYEE_DATA.EMPLOYEE_ID,extract(month from to_date('01/10/2016','dd/mm/yyyy')),extract(year from to_date('01/10/2016','dd/mm/yyyy'))),0) as MissionDays
FROM PROF_COMPANY_DETAILS 
 RIGHT JOIN PROF_BRANCHES_DETAILS ON PROF_COMPANY_DETAILS.COMPANY_ID = PROF_BRANCHES_DETAILS.COMPANY_ID 
RIGHT JOIN PROF_GENERAL_DEPARTMENT ON PROF_BRANCHES_DETAILS.BRANCH_ID = PROF_GENERAL_DEPARTMENT.BRANCH_ID 
RIGHT JOIN PROF_COMPANY_DEPARTMENTS ON PROF_GENERAL_DEPARTMENT.GENERAL_DEPT_ID = PROF_COMPANY_DEPARTMENTS.GENERAL_DEPT_ID 
RIGHT JOIN PROF_TREE_DETAILS ON PROF_COMPANY_DEPARTMENTS.COMPANY_DEPT_ID = PROF_TREE_DETAILS.COMPANY_DEPT_ID 
RIGHT JOIN PROF_EMPLOYEE_DATA ON PROF_EMPLOYEE_DATA.TREE_ID = PROF_TREE_DETAILS.TREE_ID 
LEFT JOIN PROF_JOBS_DETAILS ON PROF_JOBS_DETAILS.JOB_ID = PROF_EMPLOYEE_DATA.JOB_ID 
inner JOIN PROF_TASKS ON PROF_EMPLOYEE_DATA.EMPLOYEE_ID = PROF_TASKS.EMPLOYEE_ID
where PROF_BRANCHES_DETAILS.BRANCH_ID = 15 and prof_general_department.general_dept_id = 163 
and PROF_COMPANY_DEPARTMENTS.COMPANY_DEPT_ID = 333
AND PROF_TREE_DETAILS.TREE_ID = 571
AND (PROF_EMPLOYEE_DATA.EMP_NAME_AR IS NOT NULL) AND (PROF_EMPLOYEE_DATA.SHIFT_ID IS NOT NULL) and PROF_EMPLOYEE_DATA.action_id=1
AND PROF_EMPLOYEE_DATA.TREE_ID is not null
AND PROF_EMPLOYEE_DATA.IS_DELETED=0


"GETEMPLOYEE_MASSIONDAYS" :- "%s: invalid identifier"
Posted
Updated 25-Dec-16 10:24am
v2

This is a case of case-not-match in table/column names...
You are using, for instance, prof_tasks and PROF_TASKS also, and by default Oracle identifiers are case sensitive, so one of them is wrong (or maybe both)...
So check your case!!!
 
Share this answer
 
v4
Comments
MahmoudOmar 25-Dec-16 7:42am    
the correct name is PROF_TASKS and i will edit it but i have the same error
Kornfeld Eliyahu Peter 26-Dec-16 1:43am    
That's only one sample hit my eyes - you should go and check all names and cases...
Maciej Los 25-Dec-16 16:22pm    
5ed!
Kornfeld Eliyahu Peter 26-Dec-16 1:43am    
Thank You!
Kornfeld Eliyahu Peter[^] is right!

Check this article Oracle / PLSQL: ORA-00904 Error Message[^] to resolve your error.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900