Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: How to get back useful error messages?

Re: How to get back useful error messages?

From: Thomas Kyte <tkyte_at_us.oracle.com>
Date: Mon, 14 Sep 1998 19:37:06 GMT
Message-ID: <36046fbd.26223517@192.86.155.100>


A copy of this was sent to roy_at_popmail.med.nyu.edu (Roy Smith) (if that email address didn't require changing) On Mon, 14 Sep 1998 15:19:48 -0400, you wrote:

>I've got a table with a variety of constraints. I'm building a data-entry
>app, and want to be able to pass back to the user useful diagnostics about
>why an operation failed. The problem is, Oracle doesn't give particularly
>useful error messages. For example, if I deliberately cause an error:
>
>SQL> insert into person (alias) values ('roy.smith');
>insert into person (alias) values ('roy.smith')
>*
>ERROR at line 1:
>ORA-01400: mandatory (NOT NULL) column is missing or NULL during insert
>
>How do I know which of the several NOT NULL columns caused the problem?

2 solutions.

1- in oracle8 the following behaviour is observed:

SQL> create table t1 ( x int not null ); Table created.

SQL> insert into t1 values ( null );
insert into t1 values ( null )

            *
ERROR at line 1:
ORA-01400: cannot insert NULL into ("TKYTE"."T1"."X")

2- in oracle7.x use a named constraint:

SQL> create table t1 ( x int

                       constraint "t1.x cannot be null" check ( x is not null )
                      );

Table created.

SQL> insert into t1 values ( null );
insert into t1 values ( null )
*
ERROR at line 1:
ORA-02290: check constraint (SCOTT.t1.x cannot be null) violated  

Thomas Kyte
tkyte_at_us.oracle.com
Oracle Government
Herndon VA

--
http://govt.us.oracle.com/ -- downloadable utilities  



Opinions are mine and do not necessarily reflect those of Oracle Corporation  

Anti-Anti Spam Msg: if you want an answer emailed to you, you have to make it easy to get email to you. Any bounced email will be treated the same way i treat SPAM-- I delete it. Received on Mon Sep 14 1998 - 14:37:06 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US