On Fri, 2004-03-19 at 19:32, Jeff Urlwin wrote:
> >
> > Here's what I'm thinking of with respect to $sth->more_results:
> Yes, but -- I think that (or me) has made problems where, maybe, DBD::Sybase
> doesn't have them. I end up checking SQLMoreResults at the end of one query
> and I think my issue was the fact that parameter returns for stored
> procedures in SQL Server don't get returned until after the last set. The
> more I think of the *mess* that is in there to support strange cases, the
> more I think I need to do it better. A pseudo example, here, for those who
> are unaware:
>
> Create procedure foo (@i int, @result int OUTPUT) as
> Begin
> set @result = @i + 1;
> update blah set val = @result where index = @i;
> select val, index from blah where index = @result;
> delete from blah where index = @result;
> select val, index, val2, val3, charval from blah where index = @i;
> End;
I ran this against Sybase, using Sybase::CTlib to get all of the
underlying protocol calls.
Here's what Sybase returns:
Got: 4040
result is 'fetchable'
Got: 4046
Got 0 rows affected
Got: 4040
result is 'fetchable'
2 1 Mar 20 2004 8:42AM
Got: 4046
Got 1 rows affected
Got: 4043
result is 'fetchable'
0
Got: 4042
result is 'fetchable'
2
The 404x code is the result type - 4040 is a "row" result, 4046 is
"command done", 4043 is "status result" (i.e. the return status from the
stored procedure), 4042 is the parameter result.
As you can see, Sybase will return the number of rows affected for
intermediate results inside of the proc (unless "SET NOCOUNT" is turned
on in the session)
When I say that a result is "fetchable" it's that it is a type of result
that can include rows. The Sybase::CTlib code looks like this:
while($dbh->ct_results($restype) == CS_SUCCEED) {
print "Got: $restype\n";
if($restype == CS_CMD_DONE) {
$rows = $dbh->ct_res_info(CS_ROW_COUNT);
print "Got $rows rows affected\n";
}
next unless $dbh->ct_fetchable($restype);
print "result is 'fetchable'\n";
while(@d = $dbh->ct_fetch) {
print "@d\n";
}
}
I haven't yet had the time to read through the rest of Tim's and your
comments - I'll try to do that later today.
Michael
--
Michael Peppler Data Migrations, Inc.
[EMAIL PROTECTED] http://www.peppler.org/
Sybase T-SQL/OpenClient/OpenServer/C/Perl developer available for short or
long term contract positions - http://www.peppler.org/resume.html