my dog learned polymorphism*
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 Android Security Essentials Live Lessons this week in the Android 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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: sql question
 
Similar Threads
Servlet hang when performing to much insert function
example of count++
Retry Failed Insert Attempt?
How to get no of Rows ?
Execution problems