File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes Missing expression Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Missing expression " Watch "Missing expression " New topic
Author

Missing expression

Padma priya Gururajan
Ranch Hand

Joined: Oct 05, 2006
Posts: 434
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.


Padma priya N.G.
Be the change you want to be - Mahatma Gandhi
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30537
    
150

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?


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Padma priya Gururajan
Ranch Hand

Joined: Oct 05, 2006
Posts: 434
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
internet detective
Marshal

Joined: May 26, 2003
Posts: 30537
    
150

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Missing expression