How to solve oracle errors such as ora-06502
When we are programming and we get an oracle error, we can capture this error in an exception block. Within this block, we could use the variable sqlerrm in order to know its description.
Here it is an example:
declare
tmp varchar2(10);
begin
tmp:=’aaaaaaaaaaaaaa’;
exception
when others then
dbms_output.put_line(sqlcode||’–>’||sqlerrm);
end;
In this example, we have forced an ora-06502 error and we have captured it with the clause “when others”. We obtain the code with the internal variable sqlcode and we can obtain its description using the internal variable sqlerrm.
I hope you enjoyed it.
![]()