A question that comes up fairly frequently revolves around how to see your errors when working with PL/SQL in SQL Developer.
Most folks are probably working in the worksheet – this is the default editor for your connection.
Let’s take a look at this sample program
CREATE OR REPLACE PROCEDURE do_nothing IS BEGIN dbms_output.put(sysdate); this should probably error OUT, RIGHT? NULL; END; /
If we were to create this procedure, we would probably expect some errors. So let’s run this in the Worksheet. I’m using Ctrl+Enter to execute this single statement.
Ok, but how do I see the errors?
This is the worksheet. The commands run here will run very similar to how they would run in SQL*Plus. So knowing this, if we change-up the process a little bit, we can start to get better feedback from SQL Developer.
Add ‘show errors’ after the create or replace, and use F5 instead of Ctrl+Enter. This will run the entire script, and ask Oracle to show us any errors for the session.
You might be wondering why the line number is off. Oracle reports back a problem on line #4. If you’ll notice our program starts on SQL Developer worksheet line #2, but Oracle database only receives the actual statement, so you can do the math here to figure out the actual problem lies on line #5.
Viewing Errors in the Explorer
The current errors for the objects can also be viewed in the database explorer. Navigate to the object and open the ‘Errors’ panel.
Working in the Procedure Editor
As the name implies, the Procedure Editor is for developing and debugging your PL/SQL code. The full power of the IDE is realized here. Ok, so how do you get started with a Procedure Editor instead of a Worksheet?
In the object explorer, right-click on ‘Procedures’ and select ‘New Procedure.’ This will open a new Procedure Editor with the default procedure template code. Now when you compile, you’ll get much better error display support.
If you have a large program with several errors you can use the right gutter scroll bar area to scan for errors (denoted in red), then mouse-over to get the error message text. If you are looking at the feedback in the ‘Compiler’ panel below, you can double-click on an error message. This will move your cursor to the linenumber, curpos.
If you are working on a large script with multiple PL/SQL objects, I recommend using the Procedure Editor to perfect your procedure code, then copying that code back to your script and running that in the worksheet. Just don’t forget to add the ‘SHOW ERRORS’ line at the end.
Disclaimer: This post was written with Oracle SQL Developer v3.1.
How can I view more than 20 errors in SQL Developer?
I keep getting this error that says:
Warning(1,1): Only first 20 issues are reported
The first error is the most important, error 21 – not so much. Esp if you fix error #1 and the rest go away, yes?
I’m guess you’re seeing this on compiles – you can see the entire error report on the Errors page of your code object.
I may have found my original issue (after upgrading today to 126.96.36.199)
Nothing happens with “sho err”, but “show err” or “show errors” does work ok.
In 188.8.131.52, using ‘sho err’ in SQL*Plus does not work
SQL> create or replace procedure x is
5 end procedure x;
7 sho err
Warning: Procedure created with compilation errors.
But show err does
ERROR at line 4:
ORA-06550: line 4, column 1:
PLS-00103: Encountered the symbol “END” when expecting one of the following:
Noting the Oracle Sql Developer v3.1 disclaimer, might that explain why “sho err” didn’t respond to F5 – run as script (instead of run as statement)? I currently have 3.0.04
Thanks for this informative & concise post!
So I tried the same code in v184.108.40.206, and I see the same behavior in the worksheet as I see in v3.1EA3. The error appears in the Script Output panel.
PROCEDURE do_nothing compiled
Warning: execution completed with warning
4/7 PLS-00103: Encountered the symbol “SHOULD” when expecting one of the following:
:= . ( @ % ;