[prev in list] [next in list] [prev in thread] [next in thread]
List: msql-mysql-modules
Subject: DBI/perl
From: "Bruce W. Perry" <bwperry () shore ! net>
Date: 1998-09-15 13:57:06
[Download RAW message or body]
hi,
Can anyone see what is going wrong in this program, as by now I probably
cannot see the forest for the trees. I've tried all kinds of valid select
statements and table names, and they all throw an exception. I've tried the
...while(@row = $sth->fetchrow_array) ... statement in and out of the eval
{ } block. The strange thing is that only $dbh->do($statement) calls do
NOT throw an exception, and return the proper number of records returned.
This is just a tiny 'debug' program that I was using to test a new database
-- all the statements I have used work fine when entered with mysql on the
command line. Thanks in advance, Bruce P.
###### begin ##########
#!/usr/local/bin/perl5
use DBI;
#initialize variables
# db,user,passwd
$database = "newdb";
$user = "bwperry";
$password = "admin";
#####################
# connect to the database
eval {
$dbh = DBI->connect("DBI:mysql:$database",$user,$password, {'RaiseError' =>
1, 'PrintError' => 0});
$statement = "select first,last from nhs_phys";
$sth = $dbh->prepare($statement) or die "Can't prepare $statement";
$rv = $sth->execute($statement) or die "Can't execute";
while (@row = $sth->fetchrow_array) {
print "$row[0]\t$row[1]\n";
}
#end eval
};
if ($@) {
print "Nothing came out: $rv.";
}
####### end ###########
Bruce W. Perry
bwperry@shore.net
http://www.parkerriver.com
-----------------------------------------------------------
Send a mail to mdomo@tcx.se with
unsubscribe msql-mysql-modules your@subscription.address
in the body of the message to unsubscribe from this list.
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic