0

hello!

As i am trying to insert multiple rows using following command

insert into customer(c_id,c_name,c_city,c-street)
             values('C101','Hayes','Downtown','Main'),
                       ('C102','Willum','Perryridge','North'),
                       ('c103','Smit','Brooklyn','Park');

It always gives me an error that
[TEX]
ERROR at line 2:
command not properly ended
[/TEX]


Please tell me why this error is occuring & what's solution to it?
I am using ORACLE database for execution of this query
i.e. oracle work screen iSQL*Plus.

4
Contributors
5
Replies
7
Views
8 Years
Discussion Span
Last Post by Princeomari
0

hello!

As i am trying to insert multiple rows using following command

insert into customer(c_id,c_name,c_city,c-street)
             values('C101','Hayes','Downtown','Main'),
                       ('C102','Willum','Perryridge','North'),
                       ('c103','Smit','Brooklyn','Park');

It always gives me an error that

ERROR at line 2:
command not properly ended

Please tell me why this error is occuring & what's solution to it?
I am using ORACLE database for execution of this query
i.e. oracle work screen iSQL*Plus.

You can`t insert multiples records in a simple INSERT statement.
For insert multiples records in one INSERT statement, you need use the INSERT as SELECT:

insert into customer(c_id,c_name,c_city,c-street)
select 'C101' as c_id,'Hayes'  as c_name,'Downtown'   as c_city,'Main'  as "c-street" from dual
select 'C102' as c_id,'Willum' as c_name,'Perryridge' as c_city,'North' as "c-street" from dual
select 'c103' as c_id,'Smit'   as c_name,'Brooklyn'   as c_city,'Park'  as "c-street" from dual;
0

You can`t insert multiples records in a simple INSERT statement.
For insert multiples records in one INSERT statement, you need use the INSERT as SELECT:

insert into customer(c_id,c_name,c_city,c-street)
select 'C101' as c_id,'Hayes'  as c_name,'Downtown'   as c_city,'Main'  as "c-street" from dual
select 'C102' as c_id,'Willum' as c_name,'Perryridge' as c_city,'North' as "c-street" from dual
select 'c103' as c_id,'Smit'   as c_name,'Brooklyn'   as c_city,'Park'  as "c-street" from dual;

Ooooops!,

Sorry,

We need the union for the three select's

insert into customer(c_id,c_name,c_city,c-street)
select 'C101' as c_id,'Hayes'  as c_name,'Downtown'   as c_city,'Main'  as "c-street" from dual
select 'C102' as c_id,'Willum' as c_name,'Perryridge' as c_city,'North' as "c-street" from dual
select 'c103' as c_id,'Smit'   as c_name,'Brooklyn'   as c_city,'Park'  as "c-street" from dual;insert into customer(c_id,c_name,c_city,c-street)
select 'C101' as c_id,'Hayes'  as c_name,'Downtown'   as c_city,'Main'  as "c-street" from dual
UNION select 'C102' as c_id,'Willum' as c_name,'Perryridge' as c_city,'North' as "c-street" from dual
UNION select 'c103' as c_id,'Smit'   as c_name,'Brooklyn'   as c_city,'Park'  as "c-street" from dual;
0

hello!

As i am trying to insert multiple rows using following command

insert into customer(c_id,c_name,c_city,c-street)
             values('C101','Hayes','Downtown','Main'),
                       ('C102','Willum','Perryridge','North'),
                       ('c103','Smit','Brooklyn','Park');

It always gives me an error that
ERROR at line 2:
command not properly ended

Please tell me why this error is occuring & what's solution to it?
I am using ORACLE database for execution of this query
i.e. oracle work screen iSQL*Plus.

The code you are using is not supported in oracle .
You need to create separate insert statements for each row of data.

0

Hi,
What you can do is to insert into the customer table for each row.
hope it solves the issue for u

0

Hi,
What you can do is to insert into the customer table for each row.
hope it solves the issue for u

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.