ORA-06512
In fact, ORA-06512 does not throw the actual error it encountered. Instead, it points out the problem line in the PL/SQL program unit in error stack. For example:
SQL> declare
2 v_num number;
3 begin
4 v_num := '2 + 2';
5 dbms_output.put_line('The number is ' || v_num);
6 end;
7 /
declare
*
ERROR at line 1:
ORA-06502: PL/SQL: numeric or value error: character to number conversion error
ORA-06512: at line 4
In the above example, ORA-06512 told you that there's an error at line 4 and the true error is ORA-06502.
In real cases, PL/SQL code may be far more complex than this case. All you have to do is to trace the problem from one line to another in the error stack. The true error is usually at the top of the stack.
There're some patterns of ORA-06512 can also be found in Oracle documentation:
Please click on the following tag for more error patterns on ORA-06512.