Attached are 2 files. One is a build script for a Sybase stored procedure (fill in the database name). The other is a perl script (fill in the connection information).
The reason I am raising this issue is that I found I had to code for special conditions during error handling because execute() was returning a -1 in a specific error condition. I am assuming that undef should be returned in error conditions.
Thanks.
Glen Sievertson.
From: Michael Peppler <[EMAIL PROTECTED]> To: G S <[EMAIL PROTECTED]> Subject: Re: Bug in Sybase driver? Date: 03 Mar 2003 08:02:11 -0800
On Sat, 2003-03-01 at 11:43, G S wrote:
> I am tracking down an issue where an error condition is not returned from a
> call to $sth->execute().
>
> Here is my example code with comments. I show the output for 3 tests. Test
> 1 and test 2 produce results that I understand. The problem is in test 3.
> In test 3 I would expect the returned value (retCode) for the error
> condition to be undefined or 0. Instead it is -1. Is this a bug in the
> Sybase driver? If so, how do I report such bugs?
Please send me (the author of the module) a script that illustrates the problem.
You can also enter a bug at http://www.peppler.org/cgi-bin/bug.cgi
Michael -- Michael Peppler Data Migrations, Inc. [EMAIL PROTECTED] http://www.mbay.net/~mpeppler Sybase T-SQL/OpenClient/OpenServer/C/Perl developer available for short or long term contract positions - http://www.mbay.net/~mpeppler/resume.html
_________________________________________________________________
Add photos to your messages with MSN 8. Get 2 months FREE*. http://join.msn.com/?page=features/featuredemail
use ??" go
create proc error_test
@msg char(30)
as
begin
print @msg
return 0
end
gogrant execute on error_test to ???? go
#!/usr/bin/perl use DBI;
$msg = 12345;
$dbh = DBI->connect("DBI:Sybase:server=???;database=???", ""???", "???");
# This query is set up to produce a successful result. All values returned from DBI
# methods are -1.
# To force an error in this query, remove the quotes around $msg. This produces an datatype
# mismatch error, but a -1 is returned from $sth->execute(). I believe undef would
# be the correct return value.
# To force a different error, change the stored_procedure name to one that does not match
# a stored procedure object in your database. This produces an error, and undef is
# returned from $sth->execute(), which I think is the correct return value for the error.
# Whichever way is correct, it would be nice if the returned values were consistent. This
# would allow for the consistent coding of error handlers.
$sql_query = qq[ declare [EMAIL PROTECTED] char(30) declare [EMAIL PROTECTED] int
exec error_test
[EMAIL PROTECTED]"$msg",
[EMAIL PROTECTED]@status output
];$sth = $dbh->prepare(qq[$sql_query]);
$retCode = $sth->execute();
print "\nafter execute retCode is: $retCode \n";
printf("dbh->err= '%s'\n" .
"dbh->errstr= '%s'\n",
$dbh->err,
$dbh->errstr
);do
{
while($data = $sth->fetch)
{
if($sth->{syb_result_type} == 4042)
{ # it's a param result
$status = $data->[0];
}
}
}
while($sth->{syb_more_results});print "\nafter fetch\n";
printf("dbh->err= '%s'\n" .
"dbh->errstr= '%s'\n",
$dbh->err,
$dbh->errstr
);$retcode = $sth->finish();
print "\nafter finish retCode is: $retCode \n";
printf("dbh->err= '%s'\n" .
"dbh->errstr= '%s'\n",
$dbh->err,
$dbh->errstr
);$retcode = $dbh->disconnect();
print "\nafter disconnect retCode is: $retCode \n";
printf("dbh->err= '%s'\n" .
"dbh->errstr= '%s'\n",
$dbh->err,
$dbh->errstr
);