SQLPlus ERRORLOGGING does not keep error log on rollback
Recently I'm heavily involved in SQL*Plus scripting automation tasks. I must admit that despite all the settings you may set and retrieve with SQL*Plus, it is a real pain to do some good automation with this tool. I'm very glad that Oralce continues to extend Oracle SQL*Plus features, but i must say that it seems like the design details for those new features are not well thought, which gives me a headache when working with this tool and forces me to look for tricks and workarounds for badly designed functionality. In this post I'll write about the downsides of the ERRORLOGGING feature introduced with SQL*Plus 11.1 and above.
The feature itself is described in the Oracle documentation, so i will not reedit it here. For purposes of the post i'm using the Oracle sample schema HR. The SET ERRORLOGGING ON command however will not give you the expected results in some cases. Follow the examples to see the ERRORLOGGING fail to log errors into errors table. Lets first create the error logging table.
CREATE TABLE sperrorlog(
username VARCHAR(256),
timestamp TIMESTAMP,
script VARCHAR(1024),
identifier VARCHAR(256),
message CLOB,
statement CLOB
);
Once done, we can see it's working with the following script.