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

Home -> Community -> Usenet -> c.d.o.misc -> Re: Exceptions

Re: Exceptions

From: Thomas Kyte <tkyte_at_us.oracle.com>
Date: Tue, 01 Feb 2000 11:49:07 -0500
Message-ID: <2g3e9skgsvsj8tcs4j1ltsrnrqg2qbea2t@4ax.com>


A copy of this was sent to mavericktheman_at_my-deja.com (if that email address didn't require changing) On Tue, 01 Feb 2000 16:16:21 GMT, you wrote:

>Hi,
>I need to understand the
>"DUP_VAL_ON_INDEX"-Exception.
>
>Can anyone describe me, how this one exactly work
>?
>

if you attempt to insert into a table a value that already exists and there is a unique constraint/primary key/unique index on that column(s) -- you will get a dup_val_on_index.

For example:

ops$tkyte_at_dev8i> create table t ( X INT primary key );

Table created.

ops$tkyte_at_dev8i>
ops$tkyte_at_dev8i> insert into t values (1);

1 row created.

ops$tkyte_at_dev8i> 
ops$tkyte_at_dev8i> 
ops$tkyte_at_dev8i> begin
  2          insert into t values ( 1 );
  3  exception
  4          when DUP_VAL_ON_INDEX then
  5                  dbms_output.put_line( 'that value already exists in that
table' );
  6 end;
  7 /
that value already exists in that table

PL/SQL procedure successfully completed.

>Thanks for your help
>
>Martin
>
>
>Sent via Deja.com http://www.deja.com/
>Before you buy.

--
See http://osi.oracle.com/~tkyte/ for my columns 'Digging-in to Oracle8i'... Current article is "Part I of V, Autonomous Transactions" updated June 21'st  

Thomas Kyte                   tkyte_at_us.oracle.com
Oracle Service Industries     Reston, VA   USA

Opinions are mine and do not necessarily reflect those of Oracle Corporation Received on Tue Feb 01 2000 - 10:49:07 CST

Original text of this message

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