Home » SQL & PL/SQL » SQL & PL/SQL » how cath data duplicate in Forall Insert exception dup_val_on_index
how cath data duplicate in Forall Insert exception dup_val_on_index [message #393447] Sun, 22 March 2009 22:12 Go to next message
Theracersman
Messages: 28
Registered: November 2007
Location: Indonesia
Junior Member

hi everyone, i need help for finish my work in pl/sql.
i have array and i want to insert with forall,and than
how to catch a duplicate data when insert with forall.

Loop
v_attr(v_line_idx).field_1 := 'Test';
End loop;

Begin

forall ix in 1 .. v_line_idx
insert into table_one values v_attr(ix);

commit;

Exception
when dup_val_on_index then

insert into table error(field_err)
values (v_attr(v_line_idx).field_1);
End;
Re: how cath data duplicate in Forall Insert exception dup_val_on_index [message #393448 is a reply to message #393447] Sun, 22 March 2009 22:18 Go to previous messageGo to next message
BlackSwan
Messages: 25046
Registered: January 2009
Location: SoCal
Senior Member
You need to help us by following the Posting Guidelines as stated below.
http://www.orafaq.com/forum/t/88153/0/
So we can help you & please be consistent & correct in your postings.

Post DDL for tables.
Post DML for test data.

Post expected/desired results.

Re: how cath data duplicate in Forall Insert exception dup_val_on_index [message #393450 is a reply to message #393447] Sun, 22 March 2009 23:03 Go to previous messageGo to next message
trivendra
Messages: 208
Registered: October 2007
Location: Noida, India
Senior Member
After FORALL statement use SAVE EXCEPTIONS

FORALL IX IN 1 .. V_LINE_IDX SAVE EXCEPTIONS


example at

http://www.oracle.com/technology/sample_code/tech/pl_sql/htdocs/x/Bulk_Binding_Enhancements/Handling_And_Reporting_Exceptions.htm

Thanks
Trivendra

[Updated on: Sun, 22 March 2009 23:05]

Report message to a moderator

Re: how cath data duplicate in Forall Insert exception dup_val_on_index [message #393472 is a reply to message #393450] Mon, 23 March 2009 00:23 Go to previous message
Theracersman
Messages: 28
Registered: November 2007
Location: Indonesia
Junior Member

thnx, with save exceptions. i can catch index array..
thnk u very much..
Previous Topic: need help writing a query
Next Topic: PLS-00114: identifier too long error (merged)
Goto Forum:
  


Current Time: Thu Dec 08 08:37:39 CST 2016

Total time taken to generate the page: 0.14968 seconds