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/; |
d23f094e |
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 |
aa8b8190 |
15 | # '/' when system naming is active |
d23f094e |
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 | |
32a46300 |
26 | sub _sql_maker_opts { |
f1f56aad |
27 | my ($self) = @_; |
28 | |
32a46300 |
29 | return { |
f1f56aad |
30 | limit_dialect => 'FetchFirst', |
31 | name_sep => $self->_dbh->get_info(41) |
32a46300 |
32 | }; |
f1f56aad |
33 | } |
34 | |
d23f094e |
35 | 1; |
36 | |
37 | =head1 NAME |
38 | |
f1f56aad |
39 | DBIx::Class::Storage::DBI::ODBC::DB2_400_SQL - Support specific to DB2/400 |
d23f094e |
40 | over ODBC |
41 | |
42 | =head1 SYNOPSIS |
43 | |
44 | # In your table classes |
45 | __PACKAGE__->load_components(qw/PK::Auto Core/); |
46 | __PACKAGE__->set_primary_key('id'); |
47 | |
d23f094e |
48 | |
49 | =head1 DESCRIPTION |
50 | |
f1f56aad |
51 | This class implements support specific to DB2/400 over ODBC, including |
52 | auto-increment primary keys, SQL::Abstract::Limit dialect, and name separator |
32a46300 |
53 | for connections using either SQL naming or System naming. |
d23f094e |
54 | |
55 | |
56 | =head1 AUTHORS |
57 | |
2a57124d |
58 | Marc Mims C<< <marc@sssonline.com> >> |
d23f094e |
59 | |
aa8b8190 |
60 | Based on DBIx::Class::Storage::DBI::DB2 by Jess Robinson. |
61 | |
d23f094e |
62 | =head1 LICENSE |
63 | |
64 | You may distribute this code under the same terms as Perl itself. |
65 | |
66 | =cut |