Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

splitting a resultset

Status
Not open for further replies.

lowbk

Technical User
Nov 26, 2001
162
0
0
SG
hi guys, suppose i have a SQL statement like

select name, class, marks
from studentresult
where subject="maths"

the resultset has 3 columns something like

bob 5n6 90
peter 5n6 55
mary 5n9 99
... ... ..

now, if i wanna split the resultset to 3 separate resultsets like

bob
peter
mary
...


5n6
5n6
5n9
...


90
55
99
..

is it possible?
or will it be easier if i modify the original sql statement to 3 sql statments? if i need to use the 2nd option, it will not be manual rewriting the sql, i'll need a method to rewrite it

any kind soul pls advise
 
Hi, of cours you can split results in as many pieces as you want using some collection like a Vector as an example ( one for each column you collect from the resultset ). Another approach could be to build a class according to the fields you are expecting from the resultset. Then for each record in a resultset, you would create a new object from your brand new class. Each object in turn can be placed in a list or a vector the one that best fit for your application.

Best regards

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top