Kraken Kraken - 4 years ago 156
Perl Question

fetchrow_array returns extra 0 in the end

I am calling the sybase stored proc below from perl

create procedure testprocedure2 as
begin
select 'one'
end
GO


In perl I use DBI

do {
while(my @row = $sth->fetchrow_array()){
print $row[0]."\n";
}
} while ($sth->{syb_more_results});


As a result, I get

One
0


Why am i getting an extra 0 in the end?

Answer Source

Based on a quick look around the web, I'm guessing you have to look at $sth->{syb_result_type} and ignore the result types in which you aren't interested.

Read both the docs for DBD::Sybase (which documents $sth->{syb_result_type}) and this (which describes the result types a little).

I think the 0 is the CS_STATUS_RESULT, the result of the stored procedure. I think I found corroboration that zero indicates success.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download