Home » SQL & PL/SQL » SQL & PL/SQL » problem in insert statment
problem in insert statment [message #222124] Thu, 01 March 2007 23:51 Go to next message
sherya
Messages: 11
Registered: February 2007
Location: noida, sec-15
Junior Member
hello all



SQL> insert into emp2 values (select client_no, name, dept_no, sal, job from emp1);
insert into emp2 values (select client_no, name, dept_no, sal, job from emp1)
                         *
ERROR at line 1:
ORA-00936: missing expression


SQL> desc emp1
 Name                                                  Null?    Type
 ----------------------------------------------------- -------- -------------------------
 CLIENT_NO                                                      NUMBER(3)
 NAME                                                           VARCHAR2(12)
 JOB                                                            VARCHAR2(10)
 SAL                                                            NUMBER(10)
 DEPT_NO                                                        NUMBER
 COMM                                                           NUMBER(5)
 INCENTIVE                                                      NUMBER(5)

SQL> desc emp2
 Name                                                  Null?    Type
 ----------------------------------------------------- -------- -------------------------
 EMP_ID                                                         NUMBER
 SURNAME                                                        VARCHAR2(12)
 DEPT                                                           NUMBER
 SALARY                                                         NUMBER
 CATEGORY                                                       VARCHAR2(12)



please tell me what mistake i had done.

thanks in advance

regards
Re: problem in insert statment [message #222128 is a reply to message #222124] Fri, 02 March 2007 00:05 Go to previous messageGo to next message
dhananjay
Messages: 635
Registered: March 2002
Location: Mumbai
Senior Member
hi,

Quote:
SQL> insert into emp2 values (select client_no, name, dept_no, sal, job from emp1);
insert into emp2 values (select client_no, name, dept_no, sal, job from emp1)


its
insert into emp2
select client_no, name, dept_no, sal, job from emp1



regards,
Re: problem in insert statment [message #222138 is a reply to message #222124] Fri, 02 March 2007 00:23 Go to previous messageGo to next message
sherya
Messages: 11
Registered: February 2007
Location: noida, sec-15
Junior Member
thanks dhananjay

its working fine.



  1* insert into emp2 values as select client_no, name, dept_no, sal, job from emp1
SQL> /
insert into emp2 values as select client_no, name, dept_no, sal, job from emp1
                        *
ERROR at line 1:
ORA-00906: missing left parenthesis


SQL> ed
Wrote file afiedt.buf

  1* insert into emp2  select client_no, name, dept_no, sal, job from emp1
SQL> /

12 rows created.



at first, i got the following error by which i got confused.
can u please tell me one thing- whether this error showing anything meaningful.
here it shows that i missed values keyword, when placed values over it again it shows -- missing parenthese.

SQL> insert into emp2 as select client_no, name, dept_no, sal, job from emp1;
insert into emp2 as select client_no, name, dept_no, sal, job from emp1
                 *
ERROR at line 1:
ORA-00926: missing VALUES keyword



regards
Re: problem in insert statment [message #222143 is a reply to message #222138] Fri, 02 March 2007 00:37 Go to previous messageGo to next message
dhananjay
Messages: 635
Registered: March 2002
Location: Mumbai
Senior Member
hi,


that's bcoz the syntax which you are using to insert records is incorrect.
Quote:
insert into emp2 as select client_no, name, dept_no, sal, job from emp1;
insert into emp2 as select client_no, name, dept_no, sal, job from emp1


just get rid of the "as" and you are thru.you can go through the doc. for more information

regards,
Re: problem in insert statment [message #222162 is a reply to message #222124] Fri, 02 March 2007 02:00 Go to previous message
sherya
Messages: 11
Registered: February 2007
Location: noida, sec-15
Junior Member
thanks dhananjay Razz


regards

sherya
Previous Topic: sql lob data type
Next Topic: date
Goto Forum:
  


Current Time: Sat Dec 10 16:25:14 CST 2016

Total time taken to generate the page: 0.07816 seconds