Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Is WHENEVER SQLERROR EXIT FAILURE any good when the script contain DDLs ?

greenyOct 17 2012 — edited Oct 17 2012
Version: 11.2.0.2

I always come across SQL scripts with WHENEVER SQLERROR .... Isnt this feauture useless when there are DDLs in the script ?

sample sql script
set echo on
set feedback on
WHENEVER SQLERROR EXIT FAILURE

spool mylog.txt


create table testertab1 (ename varchar2(5));

create table testertab2 as select * from all_objects;

insert into testertab1 values ('PEDRO');
insert into testertab1 values ('JONATHAN');

commit;

spool off
The second INSERT will error out, but both of the above 2 CREATE TABLE DDLs cannot be rolled back ; so there is no point in having WHENEVER SQLERROR.. . Right ?

But I have come across lot of SQL scripts with CTAS which has WHENEVER SQLERROR EXIT FAILURE. Maybe the developers don't understand the use of this SQL*Plus feauture correctly.


Any idea why P.Forstman is using WHENEVER SQLERROR EXIT FAILURE in his example in the below thread ?
921719
This post has been answered by Sven W. on Oct 17 2012
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 14 2012
Added on Oct 17 2012
4 comments
10,644 views