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
-
- $sth->execute($self->db_schema, $table) or die;
+ 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'}
+ );
+
+ $sth->execute($self->db_schema, $table) or die $DBI::errstr;
my %keydata;
while(my $row = $sth->fetchrow_arrayref) {