Question: I was wondering what would be the preferred technique in Oracle to copy multiple records into a database that ignored duplicate values on a certain index. the statements are stated explicitly in the statement and don't come from another table

```
INSERT INTO EXAMPLE (A, B, C, D) VALUES (null,'example1','example2',EXAMPLE_SEQ.nextval);
INSERT INTO EXAMPLE (A, B, C, D) VALUES (null,'example2','example3',EXAMPLE_SEQ.nextval);
INSERT INTO EXAMPLE (A, B, C, D) VALUES (null,'example4','example5',EXAMPLE_SEQ.nextval);

```

I am currently doing it like this and checking manually, but need to find a way so that these can be handled as scripts

Answer: 
If you've decided to stick with `INSERTs` you can prevent insertion of duplicate rows by using constraints whether it primary key or unique key. If it happens to violate a unique constraint your script will stop and you'll have to roollback all changes made by previous inserts(unless you have committed every single of them). To handle that exception you could write a similar pls/sql block.

```
declare
  l_unique_exception exception;
  pragma exception_init(l_unique_exception, -1);
begin
  insert into test(id, test_vector)
    values(1, 123);
  insert into test(id, test_vector)
   values(1, 123);
  ......
  Insert into 
  commit;
exception
  when l_unique_exception
    then process the exception;    
end;  

```

**IN ADDITION**

If you want to proceed after one of the inserts raises an exception then the following example might be in handy.

1. Create a table that going to contain errors. For example.

`CREATE TABLE tb_errors (
 ErrorTag varchar2(123)
)`
2. Provide an error logging invoking [CREATE\_ERROR\_LOG](http://docs.oracle.com/cd/B19306_01/appdev.102/b14258/d_errlog.htm) procedure of [DBMS\_ERRLOG](http://docs.oracle.com/cd/B19306_01/appdev.102/b14258/d_errlog.htm) package

`DBMS_ERRLOG.CREATE_ERROR_LOG('YourDmlTable. Test in this case', 'tb_errors');`
3. Add `log errors into` clause to each `insert`

Here is an example

```
declare
begin
  insert into test(id, col1)
     values(1, 123)
     log errors into tb_errors('simple expression') reject limit unlimited;   
  insert into test(id, col1)
     values(1, 123)
     log errors into tb_errors('simple expression') reject limit unlimited;   
  insert into test(id, col1)
     values(1, 123) 
     log errors into tb_errors('simple expression') reject limit unlimited;
  commit;
end;

```

After your script is completed you can query error logging table, `tb_errors` in this case, to see what went wrong.
I suggest you to use LOG error clause if you have a goal to provide additional treatment of incorrect data. Please consider <http://www.oracle-base.com/articles/10g/dml-error-logging-10gr2.php> - good example is there.