$dbh->tables() returns nothing

J

Julia deSilva

Hi there all,

Unix Perl MYSQL

Has anyone experienced on some servers ...

my @tables = $dbh->tables() returning nothing Nil Nada zilch when you are
100% sure you have oodles of tables ?

Is this a known problem, is there a fix, workaround ?

TIA and Merry Xmas.

J
 
J

James Willmore

Unix Perl MYSQL

Has anyone experienced on some servers ...

my @tables = $dbh->tables() returning nothing Nil Nada zilch when
you are 100% sure you have oodles of tables ?

Is this a known problem, is there a fix, workaround ?

Have you done an 'execute' or 'do' before doing a 'tables' call?
Some calls to 'tables', 'rows', etc. do not return a value unless
there's an 'execute' performed first. Try something like this
(untested)

....connect as usual ...
$dbh->prepare('select * from test');
$dbh->execute;

my @tables = $dbh->tables();
.... continue with your code ...

You may want to check over the DBD::mysql and DBI documents to
(dis)prove what I've said. It ('tables') varies from vendor to vendor
and may not even be available for MySQL. So, you may have to fall
back to using an SQL statement instead.

In any event - double check the docs :)

HTH

--
Jim

Copyright notice: all code written by the author in this post is
released under the GPL. http://www.gnu.org/licenses/gpl.txt
for more information.

a fortune quote ...
Without ice cream life and fame are meaningless.
 
B

Bryan Castillo

Julia deSilva said:
Hi there all,

Unix Perl MYSQL

Has anyone experienced on some servers ...

my @tables = $dbh->tables() returning nothing Nil Nada zilch when you are
100% sure you have oodles of tables ?

Is this a known problem, is there a fix, workaround ?

TIA and Merry Xmas.

J

I haven't experience the problem, but if you need the tables in the meantime.
Here ya go:

sub show_tables {
my $dbh = shift;
my @tables;
my $st = $dbh->prepare('show tables');
$st->execute;
while (my $row = $st->fetchrow_arrayref) {
push(@tables, $row->[0]);
}
return @tables;
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top