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 If and else statements in SQL Query 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 "If and else statements in SQL Query" Watch "If and else statements in SQL Query" New topic
Author

If and else statements in SQL Query

Melvin Reynold
Greenhorn

Joined: Jun 12, 2009
Posts: 15
Im getting this error using Aqua Data Studio for below query. Thanks.

>[Error] Script lines: 1-13 -------------------------
ERROR: syntax error at or near "IF"
Line: 1

Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30057
    
149

Melvin,
To the best of my knowledge, SQL doesn't have an if statement. Is that a database specific command/stored procedure? What database are you using?


[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
Melvin Reynold
Greenhorn

Joined: Jun 12, 2009
Posts: 15
Im using this statement in XML. For the database i think its DB2.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: If and else statements in SQL Query
 
Similar Threads
Displaying a Single Record with a Comma Separated Column from Multiple Records
Special character handling
I get error with driver:may have mysql 5.1 and driver is for 5.0?
Inserting a checkbox value into database.
Struts 2 --java.lang.NullPointerException