Derk
Derk

Reputation: 1

Raise_application_error in SQL developer

I'm using SQL Developer Version 17.2.0.188. When I compile code, which cause some error, e.g. begin raise_application_error(-20001, 'xxxxx'); end;

I see the error message in script outputs(like dbms_output), but i would like to see it in a new window, similar when you declare some bind variable: variable_name number := &value; Could somebody tell me where in SQL Developer can I change the seetings to make this window visible?

I don't have option in this version of SQL developer: Tools -> Preferences -> User Interface -> Options -> DSA Dialogs...

Best regards, Derk.

Upvotes: 0

Views: 3141

Answers (1)

thatjeffsmith
thatjeffsmith

Reputation: 22427

Oracle SQL Developer doesn't work this way. Error messages are written to the Script Output or Query Result panels, depending on if your code was executed via F5 or F9, respectively.

PL/SQL compiler warnings and errors are written to the Log - Compiler panel.

enter image description here

create or replace procedure xyz123 is
begin
 null
end;
/

show errors

Additionally, if you want to see DBMS_OUTPUT included, then SET SERVEROUTPUT ON. It will get written to the Script Output panel.

enter image description here

Now, about raising an exception, this still happens in a PL/SQL block, and we'd still execute that via F5 (Script Output.)

(Code borrowed from SO answer)

DECLARE
    ex_custom EXCEPTION;
    PRAGMA exception_init ( ex_custom,-20001 );
BEGIN
    raise_application_error(
        -20001,
        'This is a custom error'
    );
EXCEPTION
    WHEN ex_custom THEN
        dbms_output.put_line(sqlerrm);
END;

Execute with F5, and...

enter image description here

Upvotes: 2

Related Questions