DBIx::SQLEngine::Mixin::SeqTable
# Classes can inherit this behavior if they don't have native sequences push @DBIx::SQLEngine::AcmeDB::ISA, 'DBIx::SQLEngine::Mixin::SeqTable'; # Public interface for SeqTable functionality $nextid = $sqldb->seq_increment( $table, $field ); # Housekeeping functions for setup and removal $sqldb->seq_create_table(); $sqldb->seq_insert_record( $table, $field ); $sqldb->seq_delete_record( $table, $field ); $sqldb->seq_drop_table();
This mixin supports SQL database servers which do natively support an auto-incrementing or unique sequence trigger. Instead, a special table is allocated to store sequence values, and queries are used to atomically retrieve and increment the sequence value to ensure uniqueness.
Constant 'dbix_sqlengine_seq'.
$sqldb->seq_create_table()
Issues a SQL create table statement to create the sequence table.
$sqldb->seq_drop_table()
Issues a SQL drop table statement to remove the sequence table.
$sqldb->seq_insert_record( $table, $field )
Creates a record in the sequence table for a given field in a particular table.
$sqldb->seq_delete_record( $table, $field )
Removes the corresponding record in the sequence table.
$sqldb->seq_bootstrap_init( $table, $field ) : $current_value
Scans the designated field in a given table to determine its maximum value, and then stores that in sequence table.
$sqldb->seq_fetch_current( $table, $field ) : $current_value
Fetches the current sequence value.
$sqldb->seq_increment( $table, $field ) : $new_value
Increments the sequence, and returns the newly allocated value.
This is the primary "public" interface of this package.
If someone else has completed the same increment before we have, our update will have no effect and we'll immeidiately try again and again until successful.
If the table does not yet exist, attempts to create it automatically.
If the sequence record does not yet exist, attempts to create it automatically.
See DBIx::Sequence for another version of the sequence-table functionality, which greatly inspired this module.
To install DBIx::SQLEngine, copy and paste the appropriate command in to your terminal.
cpanm
cpanm DBIx::SQLEngine
CPAN shell
perl -MCPAN -e shell install DBIx::SQLEngine
For more information on module installation, please visit the detailed CPAN module installation guide.