Fix to make the Postgresql-code handle Schemas. This should be non-intrusive to non...
[dbsrgits/DBIx-Class.git] / lib / DBIx / Class / Storage / DBI / ODBC400.pm
1 package DBIx::Class::Storage::DBI::ODBC400;
2 use strict;
3 use warnings;
4
5 use base qw/DBIx::Class::Storage::DBI/;
6
7 sub last_insert_id
8 {
9     my ($self) = @_;
10
11     my $dbh = $self->_dbh;
12
13     # get the schema/table separator:
14     #    '.' when SQL naming is active
15     #    '/' when system naming is active
16     my $sep = $dbh->get_info(41);
17     my $sth = $dbh->prepare_cached(
18         "SELECT IDENTITY_VAL_LOCAL() FROM SYSIBM${sep}SYSDUMMY1", {}, 3);
19     $sth->execute();
20
21     my @res = $sth->fetchrow_array();
22
23     return @res ? $res[0] : undef;
24 }
25
26 1;
27
28 =head1 NAME
29
30 DBIx::Class::Storage::DBI::ODBC400 - Automatic primary key class for DB2/400
31 over ODBC
32
33 =head1 SYNOPSIS
34
35   # In your table classes
36   __PACKAGE__->load_components(qw/PK::Auto Core/);
37   __PACKAGE__->set_primary_key('id');
38
39
40 =head1 DESCRIPTION
41
42 This class implements autoincrements for DB2/400 over ODBC.
43
44
45 =head1 AUTHORS
46
47 Marc Mims C<< <marc@questright.com> >>
48
49 Based on DBIx::Class::Storage::DBI::DB2 by Jess Robinson.
50
51 =head1 LICENSE
52
53 You may distribute this code under the same terms as Perl itself.
54
55 =cut