我正在研究类似于下面的表结构并尝试获得上述输出。
为了实现这一点,我编写了以下 PL SQL 过程:
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)每次,我运行这个我都会得到输出,因为进程在sql developer中退出,对此有什么建议吗?
注意:我是 PL SQL 编程的新手,如果我解决这个问题的方法不正确,请纠正我。