Alexander Farber (EED) writes:
> I have the following stored procedure:
<snip>
Ah yes - the "compute by" rows...
There are two things that you need to check.
One, you need to check $sth->{syb_result_type} to see what sort of
result row you are retrieving. It you "use DBD::Sybase" you'll have
the symbolic values available (CS_COMPUTE_RESULT, CS_ROW_RESULT,
CS_STATUS_RESULT - "compute by" row, normal row, proc status
respectively).
Second the column name for the compute by rows *should* be "sum(2)"
and "sum(3)".
I put together a quick example that queries the sysprocesses table and
illustrates this:
#!/usr/local/bin/perl -w
use DBI;
use DBD::Sybase;
use strict;
my $dbh = DBI->connect('dbi:Sybase:', 'sa', '');
my $sth = $dbh->prepare("select spid, status, cpu, physical_io, suid from sysprocesses
order by suid compute sum(cpu), sum(physical_io) by suid");
$sth->execute;
do {
while(my $d = $sth->fetchrow_hashref) {
if($sth->{syb_result_type} == CS_ROW_RESULT) {
print "ROW result:\n";
} elsif($sth->{syb_result_type} == CS_COMPUTE_RESULT) {
print "COMPUTE result:\n";
}
foreach (keys(%$d)) {
print "\t$_ => $d->{$_}\n";
}
}
} while($sth->{syb_more_results});
Which produces:
troll (7:51AM):125 > perl ~/tmp/compute.pl
ROW result:
cpu => 0
spid => 2
physical_io => 0
status => sleeping
suid => 0
ROW result:
cpu => 0
spid => 3
physical_io => 0
status => sleeping
suid => 0
ROW result:
cpu => 0
spid => 4
physical_io => 0
status => sleeping
suid => 0
ROW result:
cpu => 0
spid => 5
physical_io => 0
status => sleeping
suid => 0
ROW result:
cpu => 0
spid => 6
physical_io => 87902
status => sleeping
suid => 0
ROW result:
cpu => 0
spid => 7
physical_io => 2614192
status => sleeping
suid => 0
COMPUTE result:
sum(3) => 0
sum(4) => 2702094
(etc.)
Michael
--
Michael Peppler - Data Migrations Inc. - [EMAIL PROTECTED]
http://www.mbay.net/~mpeppler - [EMAIL PROTECTED]
International Sybase User Group - http://www.isug.com
Sybase on Linux mailing list: [EMAIL PROTECTED]