--- /dev/null
+package DBIx::Class::Storage::DBI::ODBC::ACCESS;\r
+use strict;\r
+use warnings;\r
+\r
+use Data::Dump qw( dump );\r
+\r
+use base qw/DBIx::Class::Storage::DBI/;\r
+\r
+my $ERR_MSG_START = __PACKAGE__ . ' failed: ';\r
+\r
+sub insert {\r
+ my $self = shift;\r
+ my ( $source, $to_insert ) = @_;\r
+\r
+ my $bind_attributes = $self->source_bind_attributes( $source );\r
+ my ( undef, $sth ) = $self->_execute( 'insert' => [], $source, $bind_attributes, $to_insert );\r
+\r
+ #store the identity here since @@IDENTITY is connection global and this prevents\r
+ #possibility that another insert to a different table overwrites it for this resultsource\r
+ my $identity = 'SELECT @@IDENTITY';\r
+ my $max_sth = $self->{ _dbh }->prepare( $identity )\r
+ or $self->throw_exception( $ERR_MSG_START . $self->{ _dbh }->errstr() );\r
+ $max_sth->execute() or $self->throw_exception( $ERR_MSG_START . $max_sth->errstr );\r
+\r
+ my $row = $max_sth->fetchrow_arrayref()\r
+ or $self->throw_exception( $ERR_MSG_START . "$identity did not return any result." );\r
+\r
+ $self->{ last_pk }->{ $source->name() } = $row;\r
+\r
+ return $to_insert;\r
+}\r
+\r
+sub last_insert_id {\r
+ my $self = shift;\r
+ my ( $result_source ) = @_;\r
+\r
+ return @{ $self->{ last_pk }->{ $result_source->name() } };\r
+}\r
+\r
+sub sqlt_type { 'ACCESS' }\r
+\r
+1;\r
+\r
+=head1 NAME\r
+\r
+DBIx::Class::Storage::ODBC::ACCESS - Support specific to MS Access over ODBC\r
+\r
+=head1 WARNING\r
+\r
+I am not a DBI, DBIx::Class or MS Access guru. Use this module with that in\r
+mind.\r
+\r
+This module is currently considered alpha software and can change without notice.\r
+\r
+=head1 DESCRIPTION\r
+\r
+This class implements support specific to Microsoft Access over ODBC. It currently only\r
+implements functions necessary for working with auto-incremented primary keys.\r
+\r
+It is loaded automatically by by DBIx::Class::Storage::DBI::ODBC when it\r
+detects a MS Access back-end.\r
+\r
+=head1 SUPPORTED VERSIONS\r
+\r
+This module have currently only been tested on MS Access 2003 using the Jet 4.0 engine.\r
+\r
+As far as my knowledge it should work on MS Access 2000 or later, but that have not been tested.\r
+Information about support for different version of MS Access is welcome.\r
+\r
+=head1 IMPLEMENTATION NOTES\r
+\r
+MS Access supports the @@IDENTITY function for retriving the id of the latest inserted row.\r
+@@IDENTITY is global to the connection, so to support the possibility of getting the last inserted\r
+id for different tables, the insert() function stores the inserted id on a per table basis.\r
+last_insert_id() then just returns the stored value.\r
+\r
+=head1 IMPLEMENTED FUNCTIONS\r
+\r
+=head2 insert\r
+\r
+=head2 last_insert_id\r
+\r
+=head2 sqlt_type\r
+\r
+=head1 BUGS\r
+\r
+Most likely. Bug reports are welcome.\r
+\r
+=head1 AUTHORS\r
+\r
+Øystein Torget C<< <oystein.torget@dnv.com> >>\r
+\r
+=head1 COPYRIGHT\r
+\r
+You may distribute this code under the same terms as Perl itself.\r
+\r
+Det Norske Veritas AS (DNV)\r
+\r
+http://www.dnv.com\r
+\r
+\r
+\r
+=cut\r
+\r