CURSOR WITH UPDATE
- From: pdalec@xxxxxxxxx (pDale)
- Date: Tue, 11 Jul 2006 13:49:32 -0400
From looking around with Google, it would APPEAR that you canimplement 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
.
- Follow-Ups:
- Re: CURSOR WITH UPDATE
- From: Jonathan Leffler
- Re: CURSOR WITH UPDATE
- Prev by Date: Re: [dbi] Execute marks end of transaction?
- Next by Date: Re: CURSOR WITH UPDATE
- Previous by thread: RE: mysql installation problems
- Next by thread: Re: CURSOR WITH UPDATE
- Index(es):