This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

multiple resultset  RSS feed

Devaki Nihar
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using sql server version 2000
Orion 1.5.2
jdk 1.4

I am facing one problem is
In my session bean query to get records ,i am using compute function which returns multiple
records ,It works fine

Code :
--Got connection as conn
--Created Statement as stmt
--initialised resultset and resultmetadata as rs and rsmd

suppose my query is something like:

select emp.empid,emp.empname,dept.deptname
from emp,dept
where emp.deptid=dept.deptid
and dept.deptid>3
order by dept.deptid
Copute count(emp.empid) by dept.deptid

It display me all the emp's data whose deptid>3 ordered and grouped by deptid
but it display count of emp's only for the last dept in the group

[edited to add code tags]
[ April 30, 2005: Message edited by: Jeanne Boyarsky ]
Jeanne Boyarsky
author & internet detective
Posts: 37222
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch!

The compute clause is meant to present summary information. That is why it is limited to one line.

I don't think there is a way to get all that information in standard SQL. You could do another query (using group by) to calculate the totals. However, it is easier and more efficient to just do the counting in Java. You are returning the department already. If there is more than one department with the same name, you can return the deptId too. Just count the number of records as you loop through the resultset.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!