I can't do it because the first dbh is not closed. I come up with a not so bright way to do it using fetchrow_array(), so now I have two arrays. One will hold an array of colleges while I query each department in the college. It doesn't look gracious, so I will take suggestions for improvement. Thanks a bunch.
my(@colleges)=();
while (my @ary = $mysth->fetchrow_array()){
push(@colleges,
@ary); #
@ary is a reference
}
$mysth->finish();
$i = 0;
$j = 0;
foreach(@college){
print "colleges: ", @{colleges->
$i}, "\n";
$myQuery = "select d.departmentName from Colleges c join Departments d on c.college_id=d.college_id where c.id=$j";
$j++;
$deptsth = &exeQuery($mydbh, $myQuery);
while (my @ary = $deptsth->fetchrow_array())
{
push(@departments,
@ary); #
@ary is a reference
print "departments: ", @{departments->
$j}, "\n";
$i++;
}
}