Thursday, 2 May 2013

Clickable SQL*Plus Errors

Running lots of scripts in SQL*Plus is nice when they are working correctly. But what about when they fail?  Its a pain to figure out what went wrong, unless you have a log file and even then, you have to hunt the errors down.

Well, I've had enough of that.  Laziness has forced us to create clickable errors in the SQL Worksheet as part of SQL Developer.

Heres a simple example.  Take 3 statements, one of which has an obvious error.  Hitting F5 runs the script and the errors now appear in the script output.  Notice that they are coloured blue at this point to show us that they are clickable.

When you click on the error, you get taken to the point where you made the error in the worksheet.  In this case, line 3.  One of the things we wanted to do as much as possible when doing this was to keep tabs on the error should we change the file.  Above, I add a few lines and return to click on the error and it brings us to the right spot again. In this instance, line 5.

The same thing works in files.  If we have a problem in a nested file like @test/test.sql, the error is reported and we can click on it in the same way and be brought to the file at the appropriate line and column offset.

Clickable SQL*Plus Scripts

When you have a load of SQL*Plus scripts, they can be a pain to manage and just simply get around.
In the next version of SQL Developer, you'll be able to hold the ctrl key down and click on the file name and have it open up.  This also works on mac with the cmd key and clicking on the line.

Remember, hold the ctrl key down on an @file.sql or @@file.sql and the line will be decorated so you can click on it.