[Dbix-class] Strict sequence primary key

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


Ihnen, David wrote:
> You're missing the database specific facilities for this - which generally materializes as an 'auto_increment' data type (Sybase derivatives, mysql) modifier or the concept of a 'sequence' (oracle, db2, postgres(I think)) which you create and can query from with the nextval/curval functions. 

DB Specific sequences do not guarantee the necessary result.  They can 
have both gaps and 'numerically' out of sequence inserts.

> 
> David
> 
> -----Original Message-----
> From: Wes Cravens [mailto:wcravens at cortex-it.com] 
> Sent: Wednesday, January 20, 2010 1:59 PM
> To: dbix-class at lists.scsys.co.uk
> Subject: [Dbix-class] Strict sequence primary key
> 
> 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