This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes JDBC and the fly likes sql question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "sql question" Watch "sql question" New topic
Author

sql question

michael yue
Ranch Hand

Joined: Nov 20, 2003
Posts: 204
Hi all,

I have this sql statement
SELECT count(*) as svcvol,sum(Amt) as svcsum,Status,Service,Compcode from SCTABLE where Status='00' GROUP BY Service

The problem is if there is no result matches it returns nothing. I want to display something even though there is nothing like displaying the compcode and the count is 0 and the sum is 0 and so on.
Is this possible. Thanks.
Jyothi Lature
Ranch Hand

Joined: Oct 31, 2001
Posts: 60
Hi,

This looks pretty simple!!!

When you get the first row from ResultSet object by doing resultset_obj.next() and compare the value of svcvol == 0, then print the statement to be displayed.

For ex:
if (resultset_obj.next())
{
int count = rs.getInt(1);
if(count == 0)
System.out.println("NO RESULT FOUND................");

}

I dont know if this is what you wanted.


Jyothi<br />Sun Certified Java Programmer<br />Brainbench Certified for Javascript
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: sql question
 
Similar Threads
Servlet hang when performing to much insert function
How to get no of Rows ?
Retry Failed Insert Attempt?
example of count++
Execution problems