Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Missing expression

 
Padma priya Gururajan
Ranch Hand
Posts: 437
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
In the below expression
insert into emp1(employeeid) values (select max(empid) from emp1)
i get an error called "Missing expression". Can you tell me the
exact error.
Thanks.
Padma priya N.G.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34837
369
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is emp1 empty? If not, does your database support nested select statements in an insert?

Also to confirm, you have two fields in the same table: employeeid and empid?
 
Padma priya Gururajan
Ranch Hand
Posts: 437
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
empdept1 is the name of the mapping table.
emp1 is the name of the parent table

I would like to know the syntax of the insert statement when used with select in its values clause.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34837
369
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Padma,
empdept1 isn't mentioned in your initial post. That may have been a typo entering it into JavaRanch and not in your original query.

See this example of a SQL statement with a nested insert. Note that not all databases support this though so you need to check your database documentation.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic