Commit | Line | Data |
2a57124d |
1 | package DBIx::Class::Storage::DBI::ODBC::DB2_400_SQL; |
d23f094e |
2 | use strict; |
3 | use warnings; |
4 | |
2a57124d |
5 | use base qw/DBIx::Class::Storage::DBI::ODBC/; |
2ad62d97 |
6 | use mro 'c3'; |
d23f094e |
7 | |
d4f16b21 |
8 | sub _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 |
24 | sub _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 |
37 | 1; |
38 | |
39 | =head1 NAME |
40 | |
f1f56aad |
41 | DBIx::Class::Storage::DBI::ODBC::DB2_400_SQL - Support specific to DB2/400 |
d23f094e |
42 | over ODBC |
43 | |
44 | =head1 SYNOPSIS |
45 | |
d88ecca6 |
46 | # In your result (table) classes |
47 | use base 'DBIx::Class::Core'; |
d23f094e |
48 | __PACKAGE__->set_primary_key('id'); |
49 | |
d23f094e |
50 | |
51 | =head1 DESCRIPTION |
52 | |
f1f56aad |
53 | This class implements support specific to DB2/400 over ODBC, including |
54 | auto-increment primary keys, SQL::Abstract::Limit dialect, and name separator |
32a46300 |
55 | for connections using either SQL naming or System naming. |
d23f094e |
56 | |
57 | |
58 | =head1 AUTHORS |
59 | |
c1e64353 |
60 | Marc Mims C<< <marc@questright.com> >> |
d23f094e |
61 | |
aa8b8190 |
62 | Based on DBIx::Class::Storage::DBI::DB2 by Jess Robinson. |
63 | |
d23f094e |
64 | =head1 LICENSE |
65 | |
66 | You may distribute this code under the same terms as Perl itself. |
67 | |
68 | =cut |