I have the following sproc which compiles just fine:
CREATE OR REPLACE PROCEDURE SSACHDEV.SyncTeleappWithClientinfo
as
mine varchar2(1);
v_teleCaseNbr number;
v_cashwithappyn varchar2(1);
CURSOR TeleAppCursor
is
Select
distinct casenbr, cashwithappyn
from TeleApp;
BEGIN
dbms_output.put_line('begin');
open TeleAppCursor;
LOOP
fetch TeleAppCursor into v_teleCaseNbr, v_cashwithappyn;
EXIT when TeleAppCursor%NOTFOUND; -- this one has the problem
Select cashwithappyn into mine from ClientInfo where casenbr = v_teleCaseNbr and trim(cashwithappyn) is null;
END LOOP;
dbms_output.put_line('end');
END;
But when I try to run it using the following:
BEGIN
SSACHDEV.SYNCTELEAPPWITHCLIENTINFO;
END;
I get the following errrors:
ORA-01403: no data found
ORA-06512: at "SSACHDEV.SYNCTELEAPPWITHCLIENTINFO", line 21
ORA-06512: at line 2
Anyone know why? Or what I can do to avoid these problems?
It’s happening because the second
selectstatement (Select cashwithappyn into mine from ..) in the procedure returns no data. AddEXCEPTIONpart in your procedure to handle that exception.