Jan 26
Sometimes it’s quite useful to know the line number of an exception:
BEGIN
RAISE NO_DATA_FOUND;
EXCEPTION WHEN NO_DATA_FOUND THEN
/*
Parse a line with this format:
ORA-NNNNN: at "SCHEMA.PROGRAM", line NNN
and return the line number of the exception
*/
DBMS_OUTPUT.put_line(
TRIM(trailing CHR(10) FROM
SUBSTR(DBMS_UTILITY.format_error_backtrace,
INSTR(DBMS_UTILITY.format_error_backtrace,’ ‘,-1,1)+1
)
)
);
END;