Hi all,

I want to insert records in table B from table A if the primary key of table A is not found in table B. So, I wrote foll. PL/SQL code.

declare
l_request_id NUMBER;
g_end_program EXCEPTION;
CURSOR
reqs
IS SELECT REQUEST_ID FROM table_A
WHERE
ACTUAL_COMPLETION_DATE <= SYSDATE
AND STATUS_CODE = 'C'
AND PHASE_CODE = 'C'
AND PRINTER != 'noprint'
AND NUMBER_OF_COPIES > 0;
BEGIN
FOR cr IN reqs
LOOP
SELECT request_id INTO l_request_id
FROM table_B
WHERE request_id = cr.request_id;
if l_request_id is NULL
then
INSERT INTO table_B from cursor....
end if;
END LOOP;
EXCEPTION
when no_data_found then
raise g_end_program;
END;
/
But, it is giving me

declare
*
ERROR at line 1:
ORA-06510: PL/SQL: unhandled user-defined exception
ORA-06512: at line 26
ORA-01403: no data found

Pl. help.

Thanks in Adv.