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