MySQL Forums
Forum List  »  Perl

How to use DBI module to retrive the primary key of any table
Posted by: Richard Jones
Date: January 03, 2008 11:51PM

I am trying to automate the use of several programs, so that I can build it one time and the when we plug in other 'methods' to the members the programming can still work without additional work needing to be done. My last problem is trying to recover the primary key on the fly of any given table.

I see primary_key_info in the DBI module documentation, but cannot get it to work...

I would appreciate any help you can be.

Thanks...

PS> here is what I'm trying to get to work:
my $sth = $dbh->primary_key_info(qq{SELECT FROM `tablenamehere`});
$sth->execute;
$_primaryKey = $dbh->selectrow_array();
$sth->finish();
$_primaryKey should now be the primary key, but it does not work.

Options: ReplyQuote


Subject
Written By
Posted
How to use DBI module to retrive the primary key of any table
January 03, 2008 11:51PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.