Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8841973
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T10:51:01+00:00 2026-06-14T10:51:01+00:00

I have a database table with a unique constraint on it (unique (DADSNBR, DAROLEID)

  • 0

I have a database table with a unique constraint on it (unique (DADSNBR, DAROLEID) pair). I am going to be inserting multiple values into this table simultaneously, so I’d like to get it done using one query – I’m assuming this would be the faster way. My query is thus:

INSERT ALL
    INTO ACCESS (DADSNBR, DAROLEID) VALUES (68, 1)
    INTO ACCESS (DADSNBR, DAROLEID) VALUES (68, 2)
    INTO ACCESS (DADSNBR, DAROLEID) VALUES (68, 3)
    INTO ACCESS (DADSNBR, DAROLEID) VALUES (68, 4)
SELECT 1 FROM DUAL

Since there are some entries within the statement that are duplicates of those already in the database, the whole insert fails and none of the rows are inserted.

Is there a way to ignore the cases where the unique constraint fails, and just insert the ones that are unique, without having to split it up into individual INSERT statements?

Edit: I realised I probably don’t want to do this anyway, but I’m still curious as to whether it’s possible or not.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T10:51:02+00:00Added an answer on June 14, 2026 at 10:51 am

    In Oracle, statements either succeed completely or fail completely (they are atomic). However, you can add clauses in certain cases to log exceptions instead of raising errors:

    • using BULK COLLECT - SAVE EXCEPTIONS, as demonstrated in this thread on askTom,
    • or using DBMS_ERRLOG (available since 10g I think).

    The second method is all automatic, here’s a demo (using 11gR2):

    SQL> CREATE TABLE test (pk1 NUMBER,
      2                     pk2 NUMBER,
      3                     CONSTRAINT pk_test PRIMARY KEY (pk1, pk2));
    
    Table created.
    
    SQL> /* Statement fails because of duplicate */
    SQL> INSERT into test (SELECT 1, 1 FROM dual CONNECT BY LEVEL <= 2);
    
    ERROR at line 1:
    ORA-00001: unique constraint (VNZ.PK_TEST) violated
    
    SQL> BEGIN dbms_errlog.create_error_log('TEST'); END;
      2  /
    
    PL/SQL procedure successfully completed.
    
    SQL> /* Statement succeeds and the error will be logged */
    SQL> INSERT into test (SELECT 1, 1 FROM dual CONNECT BY LEVEL <= 2)
      2   LOG ERRORS REJECT LIMIT UNLIMITED;
    
    1 row(s) inserted.
    
    SQL> select ORA_ERR_MESG$, pk1, pk2 from err$_test;
    
    ORA_ERR_MESG$                                       PK1 PK2
    --------------------------------------------------- --- ---
    ORA-00001: unique constraint (VNZ.PK_TEST) violated   1   1
    

    You can use the LOG ERROR clause with INSERT ALL (thanks @Alex Poole), but you have to add the clause after each table:

    SQL> INSERT ALL
      2   INTO test VALUES (1, 1) LOG ERRORS REJECT LIMIT UNLIMITED
      3   INTO test VALUES (1, 1) LOG ERRORS REJECT LIMIT UNLIMITED
      4  (SELECT * FROM dual);
    
    0 row(s) inserted.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a database table that has a Unique Key constraint defined to avoid
I have an Oracle database table that I want to apply a unique constraint
I have a database table with a column called 'symbol', that is unique via
I am using Mysql database. I have 3 table-: table Column tier_price customer_id,sku(Unique),price,website catalog_product
i have database table like this +-------+--------------+----------+ | id | ip | date |
I'm using SQL Server 2008. I have a database table that looks like this
I have rows in an Oracle database table which should be unique for a
I have a Users table, which has a Unique constraint on the username (for
In my database I have a table like this table foo int pk int
I am trying to create a unique constraint across multiple tables. I have found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.