| Author |
multiple resultset
|
Devaki Nihar
Greenhorn
Joined: Apr 30, 2005
Posts: 20
|
|
Hi 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
internet detective
Marshal
Joined: May 26, 2003
Posts: 26489
|
|
Devaki, 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.
|
[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
|
 |
 |
|
|
subject: multiple resultset
|
|
|