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

Home -> Community -> Usenet -> c.d.o.server -> Exception halting a FORALL

Exception halting a FORALL

From: Brian Tkatch <SPAMBLOCK.Maxwell_Smart_at_ThePentagon.com.SPAMBLOCK>
Date: Fri, 23 Nov 2001 01:31:44 GMT
Message-ID: <3bfda63a.298947875@news.alt.net>


From the docs.

"When any execution of the SQL statement raises an exception, the FORALL statement halts."

Is there anyway around that, other than creating a normal loop.

An example:

CREATE TABLE MyTable(MyColumn NUMBER PRIMARY KEY); INSERT INTO MyTable VALUES (2);

CREATE OR REPLACE PROCEDURE MyProc IS

  TYPE MyType IS TABLE OF NUMBER;
  MyVar MyType := MyType(1,2,3);

BEGIN   FORALL Moo IN 1..3 INSERT INTO MyTable VALUES(MyVar(Moo));

EXCEPTION   WHEN DUP_VAL_ON_INDEX THEN NULL; END;
/

EXECUTE MyProc;

SELECT * FROM MyTable;

Because of the PRIMARY KEY violation, 2 is not written, but the FORALL then exists, and 3 never gets a chance.

Brian Received on Thu Nov 22 2001 - 19:31:44 CST

Original text of this message

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