#!/usr/bin/perl use warnings; use strict; use constant DSN => 'DBI:mysql:database=test'; use constant DBUSER => 'user'; use constant DBPASS => 'pass'; use DBI; our $dbh = DBI->connect(DSN, DBUSER, DBPASS, { AutoCommit => 0, RaiseError => 1, } ) or die "Couldn't connect to database: ",$DBI::errstr; # Create the message and get the ID my $sth = $dbh->prepare("SELECT a FROM transtest"); $sth->execute(); my $row = $sth->fetchrow_hashref; warn "$$ a=$row->{a}\n"; sleep(5); $dbh->do("UPDATE transtest SET a = ?",undef,$row->{a}+1); warn "$$ done\n";