1

I have a dynamic sql :

forall k in 1..Job_ID.COUNT Save exceptions
EXECUTE IMMEDIATE 'insert into XYZ values(:1,:2,:3)' using sequence_one.NextVal,job_id(k),Name(k);
 ///Exception handling.

On running the abouve query only one row is getting inserted.And following error is thrown:

ORA-24381: error(s) in array DML.

Any idea why above thing is happening?

1 Answer 1

4

Do you really want every inserted row to have the same sequence value in the first column? If not you should do this:

forall k in 1..Job_ID.COUNT Save exceptions
  EXECUTE IMMEDIATE 'insert into XYZ values(sequence_one.NextVal,:2,:3)'
    using job_id(k),Name(k);

Or even better (unless you have a good reason for using dynamic SQL:

forall k in 1..Job_ID.COUNT Save exceptions
  insert into XYZ values(sequence_one.NextVal, job_id(k), Name(k));
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.