Jason,
Try the "do" method instead of the "prepare" method:
use strict;
$rv = $dbh->do(qq{
UPDATE pins SET
blah = 'Y',
blah2 = $yadda,
blah3 = $yadda2
WHERE
blah4 = '$yadda3'
AND
control = $yadda4"
});
print "Number of affected rows: $rv\n";
$dbh->disconnect();
This works for me using Oracle...
HTH.
Regards,
Stacy.
Jason Ostrom wrote:
>
> I'm using DBI::Sybase to connect to a MS-SQL server, and simply struggling
> with how to find out how many rows were actually updated on a UPDATE, but
> the rows method and the return value of execute both return -1.
>
> According to Descartes and Bunce's Perl DBI book, this means the number of
> rows affected are unknown.
>
> But I need to know if the UPDATE was successful or not. Is there any way
> of getting around this? Is this a MS-SQL db server issue, or can my Perl
> code get around it?
>
> Here is the simple code for the important part:
>
> <SNIP>
> $sth = $dbh->prepare ("UPDATE pins SET blah = 'Y', blah2 = $yadda, blah3
> = $yadda2 WHERE blah4 = '$yadda3' AND control = $yadda4");
>
> $return_val = $sth->execute;
> $rows = $sth->rows;
>
> print "\nreturn_val: $return_val rows: $rows\n";
>
> $sth->finish();
> $dbh->disconnect();
> <END SNIP>
>
> Always returns -1.
>
> Any comments welcome
> -Almost Desperate