CURSOR WITH UPDATE



From looking around with Google, it would APPEAR that you can
implement a cursor WITH UPDATE in DBI, but I have not been able to
find an example of that. Would anyone happen to have a bare-bones
code framework for such a thing?

Since I should give an example of the kind of operation I hope to do...

__CODE__
my $db; # database connection
my $match = "^H[ae]";
my $stmt = "SELECT foo,bar,fee FROM baz FOR UPDATE OF bar, fee";

my $sth;
die( "\nFailed preparing SELECT:\n$db->errstr\n" )
if !( $sth = $db->prepare($stmt) );

die( "\nFailed executing SELECT:\n$db->errstr\n" )
if !$sth->execute();

while ( my ( $foo, $bar, $fee ) = $sth->fetchrow_array )
{
next if $foo !~ /$match/;

$db->do( "UPDATE baz SET bar=3,fee='fie' WHERE CURRENT OF $sth->cursor")
or die( "UPDATE FAILED: $sth->errstr\n");
}

$sth->finish;
__CODE_ENDS__

Of course, $sth->cursor don't really exist (as far as I know).

TIA!

--
pDale Campbell
.