I have this in a working script runs no problem at all.
Mysql version 3.26 I think.
Do you verify that that the query was executed?
If the query gets bad then it will never get to your while loop.
You could use DBI->trace to see what's going on.
$query = "DESCRIBE $existing_table_name";
my $sth = $dbh->prepare($query) or die "Can not prepare $query :" .
$dbh->errstr ."\n";
$sth->execute or die "Can not execute $query :" . $dbh->errstr . "\n";
my $row;
while(@row = $sth->fetchrow_array) {
print "$row[0] \n";
}
$sth->finish;
Dan
-----Original Message-----
From: Craig Williams [mailto:[EMAIL PROTECTED]]
Sent: Monday, December 30, 2002 6:49 PM
To: [EMAIL PROTECTED]
Subject: Really stuck: DBI, mysqlPP.
Ok, firstly - I don't believe this is a mysql issue as I have a working server which I
can prove and the fact I've just learnt Perl was my reason for posting here, maybe
I've screwed up the syntax.
I just installed the modules for DBI and MySQL and they seem to work great except for
one aspect. Getting column names.
Code example; (code sits in a debug sub)
my $sq = $myconn->prepare("show columns from as_codes;"); $sq->execute(); while (@tmp
= $sq->fetchrow_array()) { print $tmp[0], "\n"; }
$myconn is a working connection: the select statements work great.
The above always produces nothing, the while loop never runs. I've also tried the
"describe" sql statement but I get the same results. The table as_codes has about 12
columns. I even tried the DBI, {NAME} option but got no columns returned.
If I go into mysql admin and type the above statement then it works. Also, if I put
the above code into a loop and say force it to perform the operation 10 times, it will
work for at least 1 of them.
Is this a bug ? Where can I look next ?
thanks
Craig
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]