0

Here is my code and obviously there is something wrong with it.

INSERT INTO qdel(delno,delqty)
VALUES
(192,3422);
(1,2);
(203,20);

How to insert multiple rows of data in one statement?

1
  • You need to write three insert statements. And even if Oracle did support multi-row inserts, the rows need to be separated with a , not a ;. The semicolon ; terminates the complete statement Commented Nov 9, 2015 at 9:59

2 Answers 2

2

You trying to insert mutiple row in same table.

But your process is not valid in oracle

Try like this

INSERT ALL
 INTO qdel(delno,delqty) VALUES (192,3422)
 INTO qdel(delno,delqty) VALUES (1,2)
 INTO qdel(delno,delqty) VALUES (203,20)
select * from dual
Sign up to request clarification or add additional context in comments.

2 Comments

Yes, that works fine. But I consider there may be some more convenient way.
I have recently seen a rise in the usage of insert all - I never understood how that is more convenient than simply writing three insert statements because it doesn't remove the necessity to qualify the columns for each row.
1

You can use insert . . . select:

INSERT INTO qdel(delno, delqty)
    select 192, 3422 from dual union all
    select 1, 2 from dual union all
    select 203, 20 from dual;

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.