#! /usr/bin/perl use DBI ; $root = "root" ; $dbc = "dbi:mysql::localhost" ; $dbh = DBI->connect($dbc, $root, $passwd, {AutoCommit => 0, RaiseError => 1}) ; $dbh->{'AutoCommit'} = 0 ; $dbh->do("CREATE DATABASE xxx") ; $dbh->do("USE xxx") ; $dbh->do("CREATE TABLE test (str VARCHAR(50))") ; $str = "INSERT INTO test SET str='hello'" ; $sth = $dbh->prepare($str) ; $r = $sth->execute() ; if (! $r) { print "could not insert\n" ; } else { print "ok\n" ; $dbh->rollback() ; } $dbh->disconnect() ;