develooper Front page | perl.beginners | Postings from December 2002

Re: Really stuck: DBI, mysqlPP.

Thread Previous | Thread Next
From:
Craig Williams
Date:
December 31, 2002 07:37
Subject:
Re: Really stuck: DBI, mysqlPP.
Message ID:
20021231151122.56273.qmail@onion.perl.org
Hi,

Ok, I tried what you suggested below and upgraded mysql to the latest
version 3.23.54(stable) and still get no results.

To verify the statements do run, I changed the query to Select * from tablex
and that works fine .... also added the die statements, no errors.

thanks

Craig

"Dan Muey" <dmuey@infiniplex.com> wrote in message
news:D6D77DB239A2004BB08A240E2E71460D08FA2C@customer.infiniplex.net...
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:news@ip80.com]
Sent: Monday, December 30, 2002 6:49 PM
To: beginners@perl.org
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: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org



Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About