I am working on a table structure similar to the below and trying to get the output as mentioned.

To acheive this, I written the below PL SQL procedure:
CREATE OR replace PROCEDURE Sample_procedure
AS
TYPE list_of_names_t
IS TABLE OF emp.emp_index%TYPE;
processedindexes LIST_OF_NAMES_T := List_of_names_t();
flag emp.emp_index%TYPE;
CURSOR c1 IS
SELECT *
FROM emp
WHERE Trim(emp_id) = 'AAAAA'
ORDER BY last_maint_ts ASC;
BEGIN
dbms_output.Put('Entered the loop');
FOR rec IN c1 LOOP
SELECT emp_index
INTO flag
FROM emp
WHERE emp_id = rec.emp_id
AND last_maint_ts > rec.last_maint_ts;
IF flag IS NOT NULL THEN
processedindexes.extend;
Processedindexes(processedindexes.last) := flag;
processedindexes.extend;
Processedindexes(processedindexes.last) := rec.emp_index;
dbms_output.Put('The indexes'
||rec.emp_index
||' & '
||flag
||'refer to same emp ID');
exit;
dbms_output.Put('received NULL');
END IF;
END LOOP;
END;
1) Everytime, I run this i get the output as Process exited in sql developer, Any suggestion on this?
Note: I am new to PL SQL programming, please correct me if my approach of solving this is not right.
open sqlplus and execute the following :-
provided your procedure is compiling fine, it should display the output in dbms_output.put