[Dbix-class] SQLite problem (cannot update in iterator loop)

Daisuke Murase typester at cpan.org
Thu Jan 19 13:57:48 CET 2006


Hi all.

I just found strange behavior DBIC with SQLite3.

Here is sample script, and it's does not work on my PC.

    use strict;
    use warnings;
    
    use DBIx::Class::Loader;
    
    DBIx::Class::Loader->new(
        dsn       => 'dbi:SQLite:dbic_test.db',
        namespace => 'DBIC',
    );
    
    for ( 1 .. 100 ) {
        DBIC::Test->create( { text => "text $_", } );
    }
    
    my $test_ite = DBIC::Test->search;
    while ( my $test = $test_ite->next ) {
        $test->text( $test->text . ' updated' );
        $test->update;
    }


This script shows following error:

    DBD::SQLite::st execute failed: database table is locked(1) at
    dbdimp.c line 398 at
    /usr/local/share/perl/5.8.4/DBIx/Class/Storage/DBI.pm line 187.
    Use of uninitialized value in numeric eq (==) at
    /usr/local/share/perl/5.8.4/DBIx/Class/Row.pm line 116.  Can't
    update DBIC::Test=HASH(0x85a8c3c): row not found at dbic_test.pl
    line 20


But It's work fine using:

    my @tests = DBIC::Test->search;
    for my $test (@tests) { ... }

instead of iterator.


dbic_test.db's SQL is here:

    CREATE TABLE test (
           id INTEGER NOT NULL PRIMARY KEY,
           text TEXT
    );


Any ideas ?

--
Daisuke Murase <typester at cpan.org>




More information about the Dbix-class mailing list