Home > 11g, dba, sql, sqlplus > errorlogging in 11g

errorlogging in 11g

August 27th, 2007

This is a very neat feature in 11g.

I have a script called foo.sql


create table t(x number primary key);
insert into t(x) values (1);
insert into t(x) values (2);
insert into t(x) values (2);
insert into t(x) values (3);
commit;

It is eyes-popping that this script will return an error, but which one?

Let’s errorlog !


SQL>set errorl on
SQL> @foo

Table created.

1 row created.

1 row created.

insert into t(x) values (2)
*
ERROR at line 1:
ORA-00001: unique constraint (SCOTT.SYS_C004200) violated

1 row created.

Commit complete.

SQL> set errorl off
SQL> select timestamp,script,statement,message from sperrorlog;
TIMESTAMP  SCRIPT  STATEMENT
---------- ------- ---------------------------
MESSAGE
---------------------------------------------------------
11:18:56   foo.sql insert into t(x) values (2)
ORA-00001: unique constraint (SCOTT.SYS_C004200) violated

There is also a huge bonus :-D

You can use it with 9i and 10g databases too! Only the client must be 11g. To download the 11g client only, go to Oracle E-Delivery Website

Even small, this is one of my favorite new features!

Bookmark and Share

  1. August 27th, 2007 at 13:21 | #1

    Very nice tip Laurent!

    Dimitri

  2. August 27th, 2007 at 13:35 | #2

    Good one Laurent. Will test it soooooon.

  3. August 27th, 2007 at 14:51 | #3

    That’s a real nice tip!

    Thanks
    Patrick

  4. August 27th, 2007 at 19:27 | #4

    Is there 11g Client available for Windows ?

  5. August 27th, 2007 at 21:42 | #5

    not yet

  6. Eriks
    August 28th, 2007 at 09:32 | #6

    Does this also work for inserts as select from other table?

  7. August 28th, 2007 at 09:59 | #7

    this work for every sql command. insert/delete/alter/drop whatever…

  8. sonj
    August 13th, 2008 at 14:43 | #8
  1. August 31st, 2007 at 18:02 | #1
  2. October 23rd, 2007 at 02:42 | #2