I have a trigger that’s throwing an error, and I am not sure how to know which line of PL/SQL code is throwing that error. My error is
[Oracle]ORA-01403: no data found
ORA-06512: at
“MYSCHEMA.FOO_BI”, line 9
My trigger is something like this:
create or replace TRIGGER "MYSCHEMA"."FOO_BI"
BEFORE INSERT ON FOO REFERENCING OLD AS OLD NEW AS NEW FOR EACH ROW
DECLARE
NUM1 NUMBER;
NUM2 NUMBER;
BEGIN
-- some comment
if :new.batch_num is null then
SELECT COUNT(*) INTO :NEW.BATCH_NUM FROM FOO WHERE CORP_ID = :NEW.CORP_ID;
end if;
if :new.batch_id is null or :new.batch_id = '' then
:NEW.BATCH_ID := :NEW.CORP_ID || '-' || :NEW.BATCH_NUM;
end if;
/* etc... */
I found what looks like a similar question but the line numbering starts with the create or replace... and represents my error line as a comment, which I think must be bogus. How is the line numbering reported when an error is thrown in execution of a trigger?
The line numbering (as reported in stack traces) starts with the DECLARE being line 1. So, if you do the following:
You can see the error was reported as happening at line 9, which is actually line 13 in the source.