pl/sql table/cursor question
Hi Gurus,
I am writing a stored procedure that should calculate
the time person is spending with the most recent title
hr_table
personid, title, date_started, date_finished
1 associate 01/01/2003 01/01/2005
1 associate 01/01/2000 31/12/2002
1 assistant 01/01/1997 31/12/2000
2 assistant 01/01/1998 01/01/2008
3 associate 01/01/1998 01/01/2008
Let's say person can have two titles: associate and assistant .
Usually assistant is preceded to associate, however
sometimes there are cases when person is only in the associate position or in the assistant position.
is anyway to do it without
select title into c_title
from hr_table h
where h.personid=pid and
date_finished = (select max(date_finished) from hr_table h1 where
h1.personid = pid))
How can I make something like this
CURSOR my_time IS
SELECT personid, title, date_started, date_finished
FROM hr_table h WHERE h.personid=pid;
to look only into the most recent titles?
I would like to use cursor and/or pl/sql tables
Any input will be greatly appreciated.
Thank you in advance,
C.