This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
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: 30076
    
149

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: 30076
    
149

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
 
Similar Threads
HELP!
Display the sequence numbers on the output rows of a select in Oracle 10g
Set difference method
JQuery - jquery-1.6.2.min.js errors out
How do return double integer array from a method?