What do you want it to print? You never fetched anything and are trying to
dereference a statement handle. Please see DBI docs before proceeding.
How about putting this after execute()
while ((@foo) = $sth->fetchrow_array())
{
print joint(", ", @foo), "\n";
}
Ilya Sterin
-----Original Message-----
From: Judge Dredd [mailto:[EMAIL PROTECTED]]
Sent: Saturday, April 28, 2001 9:06 PM
To: [EMAIL PROTECTED]
Subject: perl-sql- select
Hello there!
I have a database in access and I'm trying (with perl using DBI and
DBD::ODBC in win32) to select specific fields from it and write them to a
file. The script that I'm using is the one I'm providing below. The
connection to the database works fine but I think there is a problem with
the SELECT statement. The only thing that gets printed in the file is
DBI::st=HASH(0x1914394) which is the only thing that I get as a response
when the script runs.
Do you have any ideas on this? Any help would be very much appreciated.
Thanks in advance.
#!perl
use DBI;
use strict;
my $DSN = 'driver=Microsoft Access Driver (*.mdb);
dbq=\\\\arioch\\root\\tmp\\db1.mdb';
my $dbh = DBI->connect("dbi:ODBC:$DSN") or die "$DBI::errstr\n";
$dbh->{AutoCommit} = 1;$dbh->{RaiseError} = 1;
my $sth = $dbh->prepare(q{
SELECT (DNS_id, help) FROM DNS}) || die $dbh->errstr;
chop;
$sth->execute() || die $dbh->errstr;
unless (open(ZONEFILE2, ">zonefile2")){
die ("Missing File");
}
print ZONEFILE2 "\$sth";
close(ZONEFILE2);
$sth->finish;
$dbh->disconnect;
_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com