[Dbix-class] Strict sequence primary key

Wes Cravens wcravens at cortex-it.com
Wed Jan 20 22:36:43 GMT 2010


Robert Stockdale wrote:
> *I'm not sure about how to lock the table, but you should be able to
> accomplish the rest of the transaction using the txn_do method:*

Yes indeed the transaction functionality of DBIC is part of what I'm 
after but it's not complete.  I can get the lock by accessing the dbh 
directly if need be.  But in this case I will be writing my own 'create' 
functions rather than leveraging the strength of DBIC directly.  Which 
is OK... I'm just trying to discover if there is a standard or more 
direct way that I am missing.

> *
> *
> *
> http://search.cpan.org/~frew/DBIx-Class-0.08115/lib/DBIx/Class/Storage.pm#txn_do
> *
> *
> *
> *-Bob
> *
> On Wed, Jan 20, 2010 at 4:59 PM, Wes Cravens <wcravens at cortex-it.com> wrote:
> 
>> In an effort to create strictly sequential (Incrementing Integer no gaps)
>> primary keys my method has traditionally been:
>>
>> BEGIN;
>> LOCK table;
>> SELECT MAX(id) FROM table;
>> INSERT INTO table...;
>> COMMIT;
>>
>> I'm relatively new to DBIC and have not really seen a way to do this unless
>> I create a wrapper to handle it.
>>
>> Is there something I am missing?
>>
>> Thanks,
>>
>> Wes
>>
>> _______________________________________________
>> 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/dbix-class@lists.scsys.co.uk
>>
> 
> 
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> 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/dbix-class@lists.scsys.co.uk




More information about the DBIx-Class mailing list