1

I'm using SQL Developer 20.2 to run batch scripts for Oracle 12c database updates. I drag&drop the script file into the editor window and then hit the button "Run Script (F5)". For some reason the program stops if the script runs into an error (DDL statements - no explicit throw of a PL/SQL function).

Example:

drop sequence my_seq;  -- sequence may not exist yet
create sequence my_seq
  start with 1
increment by 1
    minvalue 1
    maxvalue 9999999999
       cache 100
       cycle;

The drop statement may hit an error because the sequence does not exist. SQL*Plus ignores that error and continues to run the script but SQL Developer stops the execution resulting in an incomplete patch update.

What can I do?

2 Answers 2

5

SqlDeveloper by default stops when it finds an error. You can change that behaviour using this:

whenever sqlerror continue;
drop sequence my_seq;  -- sequence may not exist yet, in case of error continue
-- then we want to stop in error
whenever sqlerror exit failure;
create sequence my_seq
  start with 1
increment by 1
    minvalue 1
    maxvalue 9999999999
       cache 100
       cycle;

Example

enter image description here

Explanation

  • whenever sqlerror continue instructs to the script to continue no matter what error might happen
  • whenever sqlerror exit failure instructs to the script to stop and exit the execution in case of an error.

Reference to the command and options available

whenever sqlerror

Sign up to request clarification or add additional context in comments.

Comments

0

That shouldn't be happening. By default SQL Developer runs the entire contents of the editor or whatever you have selected when you hit F5.

drop sequence my_seq;  

create sequence my_seq
  start with 1
increment by 1
    minvalue 1
    maxvalue 9999999999
       cache 100
       cycle;

F5

You can see that the drop fails, but it continues onto the CREATE. This was all in one 'go'

enter image description here

2 Comments

I believe that was true for older versions. That's why I developed the code like that and never had problems. Maybe there's also a setting. Roberto Hernandez's solution works.
older, maybe decade ago...also maybe he has something in his login.sql that's setting whenever sqlerror exit, that's my best guess

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.