--Use the functions SQLERRM and SQLCODE to print error messages in PLSQL
clear screen
set serveroutput on
declare
v1 number;
begin
Select (10/0) into v1 from dual;
exception
when others then
dbms_output.put_line('
SQL Code:
'||SQLCODE||'
Error Message:
'||SQLERRM);
end;
/
Output:
SQL Code:
-1476
Error Message:
ORA-01476: divisor is equal to zero
clear screen
set serveroutput on
declare
v1 number;
begin
Select (10/0) into v1 from dual;
exception
when others then
dbms_output.put_line('
SQL Code:
'||SQLCODE||'
Error Message:
'||SQLERRM);
end;
/
Output:
SQL Code:
-1476
Error Message:
ORA-01476: divisor is equal to zero
Comments