This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

sql question

 
michael yue
Ranch Hand
Posts: 204
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic