I had posted this question to dbi-users as well (though it wasn't a dbi question, really), and now found a solution that works:
my $sql = qq|select a.column_name from user_cons_columns a, user_constraints b where a.constraint_name = b.constraint_name and a.table_name = b.table_name and b.table_name = 'TABLE_NAME' and b.constraint_type = 'P'|;
$sth = $dbh->prepare($sql);
$sth->execute();
while (my $hash_ref = $sth->fetchrow_hashref) {
my $key = $hash_ref->{COLUMN_NAME};
print "$key"; # yep: the primary key name!
}
(never mind the clumsy hashref, it's the rest that counts.)
Cheers,
kellner
my $sql = qq|select a.column_name from user_cons_columns a, user_constraints b where a.constraint_name = b.constraint_name and a.table_name = b.table_name and b.table_name = 'TABLE_NAME' and b.constraint_type = 'P'|;
$sth = $dbh->prepare($sql);
$sth->execute();
while (my $hash_ref = $sth->fetchrow_hashref) {
my $key = $hash_ref->{COLUMN_NAME};
print "$key"; # yep: the primary key name!
}
(never mind the clumsy hashref, it's the rest that counts.)
Cheers,
kellner