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

  • SEARCH
  • Home
  • 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 8888703
In Process

The Archive Base Latest Questions

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

Given this example ( DUP_VAL_ON_INDEX Exception ), is it possible to capture the values

  • 0

Given this example (DUP_VAL_ON_INDEX Exception), is it possible to capture the values that violated the constraint so they may be logged?

Would the approach be the same if there are multiple violations generated by a bulk insert?

BEGIN
  -- want to capture '01' and '02'
  INSERT INTO Employee(ID)
  SELECT ID
  FROM (
    SELECT '01' ID FROM DUAL
    UNION
    SELECT '02' ID FROM DUAL
  );

EXCEPTION
  WHEN DUP_VAL_ON_INDEX THEN
    -- log values here
    DBMS_OUTPUT.PUT_LINE('Duplicate value on an index');
END;
  • 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-14T22:06:02+00:00Added an answer on June 14, 2026 at 10:06 pm

    Ideally, I would suggest using DML error logging. For example

    Create the error log table

    begin
      dbms_errlog.create_error_log( dml_table_name => 'EMPLOYEE',
                                    err_log_table_name => 'EMPLOYEE_ERR' );
    end;
    

    Use DML error logging

    BEGIN
      insert into employee( id )
        select id 
          from (select '01' id from dual
                union all
                select '02' from dual) 
        log errors into employee_err
            reject limit unlimited;
    END;
    

    For every row that fails, this will log the data for the row into the EMPLOYEE_ERR table along with the exception. You can then query the error log table to see all the errors rather than getting just the first row that failed.

    If creating the error log table isn’t an option, you could move from SQL to PL/SQL with bulk operations. That will be slower but you could use the SAVE EXCEPTIONS clause of the FORALL statement to create a nested table of exceptions that you could then iterate over.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Given this example, how would I return the result of the equation rather than
I'm trying to solve this problem : http://uva.onlinejudge.org/external/7/732.html . For the given example, they
Given this example, how do we ensure that the thread instance has been freed?
Given this example, I get the error that follows: print u'\2033'.translate({2033:u'd'}) C:\Python26\lib\encodings\cp437.pyc in encode(self,
Given this example HTML that my GM script runs on, I want to make
Given this example, try making your window smaller such that the size of the
Given this example data set: ----------------------------- | item | date | val | -----------------------------
Given this example XML file: <doc> <tag> Hello ! </tag> <tag> My name is
Given I have a long phrase, say, in line :12 , as this example:
Given the example below, can someone please show me how this could be called?

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.