bump version to 0.03999_01, added $VERSION to all packages
[dbsrgits/DBIx-Class-Schema-Loader.git] / lib / DBIx / Class / Schema / Loader / DBI / DB2.pm
index 5ec113f..68cc311 100644 (file)
@@ -3,8 +3,11 @@ package DBIx::Class::Schema::Loader::DBI::DB2;
 use strict;
 use warnings;
 use base 'DBIx::Class::Schema::Loader::DBI';
+use Carp::Clan qw/^DBIx::Class/;
 use Class::C3;
 
+our $VERSION = '0.03999_01';
+
 =head1 NAME
 
 DBIx::Class::Schema::Loader::DBI::DB2 - DBIx::Class::Schema::Loader::DBI DB2 Implementation.
@@ -34,14 +37,14 @@ sub _table_uniq_info {
 
     my $dbh = $self->schema->storage->dbh;
 
-    my $sth = $dbh->prepare(<<'SQL') or die;
-SELECT kcu.COLNAME, kcu.CONSTNAME, kcu.COLSEQ
-FROM SYSCAT.TABCONST as tc
-JOIN SYSCAT.KEYCOLUSE as kcu ON tc.CONSTNAME = kcu.CONSTNAME
-WHERE tc.TABSCHEMA = ? and tc.TABNAME = ? and tc.TYPE = 'U'
-SQL
+    my $sth = $self->{_cache}->{db2_uniq} ||= $dbh->prepare(
+        q{SELECT kcu.COLNAME, kcu.CONSTNAME, kcu.COLSEQ
+        FROM SYSCAT.TABCONST as tc
+        JOIN SYSCAT.KEYCOLUSE as kcu ON tc.CONSTNAME = kcu.CONSTNAME
+        WHERE tc.TABSCHEMA = ? and tc.TABNAME = ? and tc.TYPE = 'U'}
+    ) or die $DBI::errstr;
 
-    $sth->execute($self->db_schema, $table) or die;
+    $sth->execute($self->db_schema, $table) or die $DBI::errstr;
 
     my %keydata;
     while(my $row = $sth->fetchrow_arrayref) {
@@ -53,6 +56,7 @@ SQL
             @{$keydata{$keyname}};
         push(@uniqs, [ $keyname => \@ordered_cols ]);
     }
+
     $sth->finish;
     
     return \@uniqs;