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.

Recommended Answers

All 5 Replies

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;

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;

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.

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

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.