#!/usr/bin/perl
use strict;
use warnings;
use DB::Main;
my ( $dbi_dsn, $user, $pass ) = ( q{dbi:mysql:testdbix}, q{root}, q{} );
my $schema = DB::Main->connect( $dbi_dsn, $user, $pass, {} );
my @rows = $schema->resultset(q{MyTable})->all;
for my $r (@rows) {
print join( q{/}, $r->mykey, $r->something, $r->altkey ), qq{\n};
}
print qq{case 1\n};
eval {
$schema->resultset(q{MyTable})->search({mykey=> 2})->update( { altkey => 10 } );
print qq{update done\n};
};
if ($@) {
print qq{exception: $@\n};
}
else {
print qq{no exception};
}
print qq{case 2\n};
eval {
$schema->resultset(q{MyTable})->search({mykey=> 2})->update( { mykey => 1 } );
print qq{update done\n};
};
if ($@) {
print qq{exception: $@\n};
}
else {
print qq{no exception};
}