New DB2 Automagic primary key collecting
[dbsrgits/DBIx-Class.git] / lib / DBIx / Class / PK / Auto / DB2.pm
1 package DBIx::Class::PK::Auto::DB2;
2
3 use strict;
4 use warnings;
5
6 use base qw/DBIx::Class/;
7
8 __PACKAGE__->load_components(qw/PK::Auto/);
9
10 sub last_insert_id
11 {
12     my ($self) = @_;
13
14     my $dbh = $self->storage->dbh;
15     my $sth = $dbh->prepare_cached("VALUES(IDENTITY_VAL_LOCAL())");
16     $sth->execute();
17
18     my @res = $sth->fetchrow_array();
19
20     return @res ? $res[0] : undef;
21                          
22 }