Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

can't insert data into table

I have created table using this command successfully

create  table Person(
  first_name varchar(25) not null,
  last_name varchar(25) not null,
  persoin_id number not null, 
  birth_date date,  
  country varchar (25),
  salary  number);

and now I want to insert data into that table

insert into  Person(persoin_id,first_name,last_name,salary,birth_date,country)
 values(100,'dato','datuashvili',350,to_date('01/01/10','DD/MM/YY'),'georgia');
 values(101,'irakli','oqruashvili',350,to_date('01/03/10','DD/MM/YY'),'georgia');

first row is inserted,but problem is with second line

1 rows inserted.

Error starting at line 10 in command:
values(101,'irakli','oqruashvili',350,to_date('01/03/10','DD/MM/YY'),'georgia')
Error report:
Unknown Command

Please help me to determine what is problem?thanks

like image 872
dato datuashvili Avatar asked Nov 26 '11 15:11

dato datuashvili


1 Answers

If you are on a RDBMS that supports multi-rows inserts in one INSERT:

insert into  Person(persoin_id,first_name,last_name,salary,birth_date,country)
   values
 (100,'dato','datuashvili',350,to_date('01/01/10','DD/MM/YY'),'georgia') , 
                                                       --- comma here ---^
 (101,'irakli','oqruashvili',350,to_date('01/03/10','DD/MM/YY'),'georgia') ;
 ^--- no "values" here

If not (like Oracle), you'll have to issue two insert statements:

insert into  Person(persoin_id,first_name,last_name,salary,birth_date,country)
   values
 (100,'dato','datuashvili',350,to_date('01/01/10','DD/MM/YY'),'georgia') ;
                                                  --- as it was  here ---^

insert into  Person(persoin_id,first_name,last_name,salary,birth_date,country)
   values
 (101,'irakli','oqruashvili',350,to_date('01/03/10','DD/MM/YY'),'georgia') ;

or use this approach:

insert into  Person(persoin_id,first_name,last_name,salary,birth_date,country)
   select
 (100,'dato','datuashvili',350,to_date('01/01/10','DD/MM/YY'),'georgia') 
       from dual
   union all select
 (101,'irakli','oqruashvili',350,to_date('01/03/10','DD/MM/YY'),'georgia') 
       from dual
 ;
like image 157
ypercubeᵀᴹ Avatar answered Sep 29 '22 08:09

ypercubeᵀᴹ