1 package DBIx::Class::Schema::Loader::DBI::DB2;
5 use base 'DBIx::Class::Schema::Loader::DBI';
6 use Carp::Clan qw/^DBIx::Class/;
9 our $VERSION = '0.04999_02';
13 DBIx::Class::Schema::Loader::DBI::DB2 - DBIx::Class::Schema::Loader::DBI DB2 Implementation.
18 use base qw/DBIx::Class::Schema::Loader/;
20 __PACKAGE__->loader_options( db_schema => "MYSCHEMA" );
26 See L<DBIx::Class::Schema::Loader::Base>.
30 sub _table_uniq_info {
31 my ($self, $table) = @_;
35 my $dbh = $self->schema->storage->dbh;
37 my $sth = $self->{_cache}->{db2_uniq} ||= $dbh->prepare(
38 q{SELECT kcu.COLNAME, kcu.CONSTNAME, kcu.COLSEQ
39 FROM SYSCAT.TABCONST as tc
40 JOIN SYSCAT.KEYCOLUSE as kcu ON tc.CONSTNAME = kcu.CONSTNAME
41 WHERE tc.TABSCHEMA = ? and tc.TABNAME = ? and tc.TYPE = 'U'}
42 ) or die $DBI::errstr;
44 $sth->execute($self->db_schema, uc $table) or die $DBI::errstr;
47 while(my $row = $sth->fetchrow_arrayref) {
48 my ($col, $constname, $seq) = @$row;
49 push(@{$keydata{$constname}}, [ $seq, lc $col ]);
51 foreach my $keyname (keys %keydata) {
52 my @ordered_cols = map { $_->[1] } sort { $a->[0] <=> $b->[0] }
53 @{$keydata{$keyname}};
54 push(@uniqs, [ $keyname => \@ordered_cols ]);
64 return map lc, $self->next::method;
68 my ($self, $table) = @_;
69 return $self->next::method(uc $table);
73 my ($self, $table) = @_;
75 my $rels = $self->next::method(uc $table);
77 foreach my $rel (@$rels) {
78 $rel->{remote_table} = lc $rel->{remote_table};
84 sub _columns_info_for {
85 my ($self, $table) = @_;
86 return $self->next::method(uc $table);
91 L<DBIx::Class::Schema::Loader>, L<DBIx::Class::Schema::Loader::Base>,
92 L<DBIx::Class::Schema::Loader::DBI>