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 Alternate SQL Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Alternate SQL" Watch "Alternate SQL" New topic
Author

Alternate SQL

Hasan Pasha
Greenhorn

Joined: Feb 23, 2005
Posts: 25
I have a SQL query that would work in Oracle... but if I change the DB then it would not work as I am using Oracle specific fn. (NVL).

I do not have much of an experience with writing SQL queries.
Some one please help me rewrite a generic query that would work on all DB.

My oracle specific query is given below.

Thanks

Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30382
    
150

Hasan,
To write that in a non-Oracle specific way, you need a subquery that returns the fields that you are adding. Then you can sum up the ones that aren't null. For example (on a smaller query),

Start with a bare bones query like that and then gradually add the rest of your query on.


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