Hi,
I have to develop an attendance processing system and I want to do entire process of attendance processing part using oracle procedure.
It is a complicated task and I already prepared the logic for all process.
while writing the procedure I will have to
- fetch data from multiple tables
- process each row in a loop.
- update variables in a loop.
- update other tables.
I am new to oracle procedure. Eventhough I found it easy to understand oracle procedures while going through the tutorial, I feel it difficult to write a procedure myself.
I have created a sample case as follows and if anybody can help me to create a procedure for that, I can learn the best way of achieving result and can expand further myself.
I have following three tables
(I) | PUNCHDATA |
Empid | payrolldate | inpunch | outpunch |
1 | 01/01/2014 | 01/01/2014 08:00 | 01/01/2014 12:00 |
1 | 01/01/2014 | 01/01/2014 12:30 | null |
1 | 01/01/2014 | 01/01/2014 15:00 | 01/01/2014 16:00 |
1 | 02/01/2014 | 02/01/2014 08:04 | 02/01/2014 16:01 |
1 | 03/01/2014 | 03/01/2014 08:45 | 03/01/2014 16:00 |
1 | 04/01/2014 | null | null |
1 | 05/01/2014 | null | null |
2 | 01/01/2014 | 01/01/2014 09:00 | 01/01/2014 16:30 |
2 | 02/01/2014 | 02/01/2014 09:04 | 02/01/2014 16:04 |
2 | 03/01/2014 | 03/01/2014 08:45 | 03/01/2014 08:45 |
2 | 04/01/2014 | null | null |
2 | 05/01/2014 | null | null |
3 | 01/01/2014 | 01/01/2014 15:00 | 01/01/2014 15:00 |
3 | 02/01/2014 | 02/01/2014 08:04 | 02/01/2014 08:04 |
3 | 03/01/2014 | 03/01/2014 08:45 | 03/01/2014 08:45 |
3 | 04/01/2014 | null | null |
3 | 05/01/2014 | null | null |
(II) | LATE | | | |
Empid | parolldate | shiftstart | shiftend | late |
1 | 01/01/2014 | 08:00 | 16:00 | |
1 | 02/01/2014 | 08:00 | 16:00 | |
1 | 03/01/2014 | 08:00 | 16:00 | |
1 | 04/01/2014 | 08:00 | 16:00 | |
1 | 05/01/2014 | 08:00 | 16:00 | |
2 | 01/01/2014 | 09:00 | 16:30 | |
2 | 02/01/2014 | 09:00 | 16:30 | |
2 | 03/01/2014 | 09:00 | 16:30 | |
2 | 04/01/2014 | 09:00 | 16:30 | |
2 | 05/01/2014 | 09:00 | 16:30 | |
3 | 01/01/2014 | 00:00 | 08:00 | |
3 | 02/01/2014 | 00:00 | 08:00 | |
3 | 03/01/2014 | 00:00 | 08:00 | |
3 | 04/01/2014 | 00:00 | 08:00 | |
3 | 05/01/2014 | 00:00 | 08:00 | |
I want to compute the Late minutes for each employee for each day based on the first in punch of the employee for the day.
5 minute late is allowed and need not be considered as late
- ie. If first punch of employee is within 5 minutes from shift start time late minutes would be zero.
if first punch of an employee for the day is processed rest of the punches for the day need not be processed.
ie . Skip directly to next day punch for that employee.
if either of or both punches are null those rows need not be processed.
I want to update late column of the table LATE when punch of each day for each employee is processed.
I also want to store the late to a variable sum it up in a loop the write to the table CUMLATE when punch of each employee is completed.
This is just a sample case and I am more focused on how to do looping,storing to variable, writing back to table etc.. than the accuracy of computed values.
I use oracle 10g.
After executing the procedure data in my tables would get updated as follows
LATE |
Empid | payrolldate | shiftstart | shiftend | late |
1 | 01/01/2014 | 08:00 | 16:00 | 0 |
1 | 02/01/2014 | 08:00 | 16:00 | 45 |
1 | 03/01/2014 | 08:00 | 16:00 | 6 |
1 | 04/01/2014 | 08:00 | 16:00 | 0 |
1 | 05/01/2014 | 08:00 | 16:00 | 0 |
2 | 01/01/2014 | 09:00 | 16:30 | 0 |
2 | 02/01/2014 | 09:00 | 16:30 | 0 |
2 | 03/01/2014 | 09:00 | 16:30 | 0 |
2 | 04/01/2014 | 09:00 | 16:30 | 0 |
2 |
New comments cannot be posted to this locked post.
|