From: Jess Robinson Date: Sun, 8 Jan 2006 16:45:46 +0000 (+0000) Subject: New DB2 Automagic primary key collecting X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=f6a3f5ae498091a233c8a96cf3a1b262ce0c5e38;p=dbsrgits%2FDBIx-Class-Historic.git New DB2 Automagic primary key collecting --- diff --git a/lib/DBIx/Class/PK/Auto/DB2.pm b/lib/DBIx/Class/PK/Auto/DB2.pm new file mode 100644 index 0000000..5c0b213 --- /dev/null +++ b/lib/DBIx/Class/PK/Auto/DB2.pm @@ -0,0 +1,22 @@ +package DBIx::Class::PK::Auto::DB2; + +use strict; +use warnings; + +use base qw/DBIx::Class/; + +__PACKAGE__->load_components(qw/PK::Auto/); + +sub last_insert_id +{ + my ($self) = @_; + + my $dbh = $self->storage->dbh; + my $sth = $dbh->prepare_cached("VALUES(IDENTITY_VAL_LOCAL())"); + $sth->execute(); + + my @res = $sth->fetchrow_array(); + + return @res ? $res[0] : undef; + +}