I am posting my code for dbi and dbix here please have a look.

* DBI here AutoCommit = 0

my $dbh = DBI->connect($dsn, $user, $password,
                      { RaiseError => 1, AutoCommit => 0 });
my $sel_sql = qq{select * from test where id = 1 for update};
my $rs = $dbh->selectrow_array($sel_sql);
sleep(10);
my $ins_sql = qq{insert into test(value1, value2) values(10.10,20.1)};
my $sth = $dbh->prepare($ins_sql);
$sth->execute();
$dbh->commit();
$dbh->disconnect();


* DBIx here AutoCommit = 0

my $schema = DB::Model::test->new();
my $rs = $schema->resultset('Test');
my $test_res = $rs->search( { 'id' => 1 }, { 'for' => 'update' } )->first();
sleep(10);
$rs->create({value1 => 10.45, value2 => 20.70});
$schema->storage->txn_commit();


here sleep(10) will hold execution for 10 second so meanwhile you can
execute same script from other terminal to generate the scenario.

Thanks,

Hardik Joshi

On Tue, Jun 19, 2012 at 2:08 PM, Dave Howorth <[email protected]>wrote:

> Hardik Joshi wrote:
> > Thanks Alex,
> >
> > I have tried 'SELECT...FOR UPDATE' with normal DBI module and its working
> > well where as via DBIx::Class its not working as per requirement.
>
> I don't understand. The code you said you had tried was doing an INSERT,
> not an UPDATE. So how is SELECT...FOR UPDATE relevant or working in DBI?
>
> > So, I feel I might missing something in DBIx::Class. do you have any idea
> > for that?
>
>
> _______________________________________________
> List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
> IRC: irc.perl.org#dbix-class
> SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
> Searchable Archive:
> http://www.grokbase.com/group/[email protected]
>
_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/[email protected]

Reply via email to