Ask for newer DBD::Pg in author mode, suggest the newer version otherwise (proper...
[dbsrgits/DBIx-Class.git] / lib / DBIx / Class / Storage / DBI / ODBC / DB2_400_SQL.pm
CommitLineData
2a57124d 1package DBIx::Class::Storage::DBI::ODBC::DB2_400_SQL;
d23f094e 2use strict;
3use warnings;
4
2a57124d 5use base qw/DBIx::Class::Storage::DBI::ODBC/;
d23f094e 6
d4f16b21 7sub _dbh_last_insert_id {
8 my ($self, $dbh, $source, $col) = @_;
d23f094e 9
d4f16b21 10 # get the schema/table separator:
11 # '.' when SQL naming is active
12 # '/' when system naming is active
13 my $sep = $dbh->get_info(41);
14 my $sth = $dbh->prepare_cached(
15 "SELECT IDENTITY_VAL_LOCAL() FROM SYSIBM${sep}SYSDUMMY1", {}, 3);
16 $sth->execute();
d23f094e 17
d4f16b21 18 my @res = $sth->fetchrow_array();
d23f094e 19
d4f16b21 20 return @res ? $res[0] : undef;
d23f094e 21}
22
32a46300 23sub _sql_maker_opts {
f1f56aad 24 my ($self) = @_;
25
a9f32dbc 26 $self->dbh_do(sub {
d4f16b21 27 my ($self, $dbh) = @_;
28
29 return {
30 limit_dialect => 'FetchFirst',
31 name_sep => $dbh->get_info(41)
32 };
a9f32dbc 33 });
f1f56aad 34}
35
d23f094e 361;
37
38=head1 NAME
39
f1f56aad 40DBIx::Class::Storage::DBI::ODBC::DB2_400_SQL - Support specific to DB2/400
d23f094e 41over ODBC
42
43=head1 SYNOPSIS
44
45 # In your table classes
46 __PACKAGE__->load_components(qw/PK::Auto Core/);
47 __PACKAGE__->set_primary_key('id');
48
d23f094e 49
50=head1 DESCRIPTION
51
f1f56aad 52This class implements support specific to DB2/400 over ODBC, including
53auto-increment primary keys, SQL::Abstract::Limit dialect, and name separator
32a46300 54for connections using either SQL naming or System naming.
d23f094e 55
56
57=head1 AUTHORS
58
c1e64353 59Marc Mims C<< <marc@questright.com> >>
d23f094e 60
aa8b8190 61Based on DBIx::Class::Storage::DBI::DB2 by Jess Robinson.
62
d23f094e 63=head1 LICENSE
64
65You may distribute this code under the same terms as Perl itself.
66
67=cut