Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

DBI error Can't locate object method "fetchrow_array"

by anasgr (Initiate)
on Aug 03, 2009 at 17:52 UTC ( [id://785515]=perlquestion: print w/replies, xml ) Need Help??

anasgr has asked for the wisdom of the Perl Monks concerning the following question:

Hello Everyone,

I am getting error "Can't locate object method "fetchrow_array" via package "sth" (perhaps you forgot to load "sth"?)", While executing the script below.
use strict; use DBI ; #use DBD::ODBC; my $sql = qq { select DISTINCT account from accountsize }; my $dbh = DBI->connect("dbi:ODBC:LocalServer") or die; my $sth = $dbh->prepare("select account from accountsize") or die "err +or" . $dbh->errstr; $sth->execute( ) or die; my @row; while (@row = sth->fetchrow_array) { print "$row[0]\n"; } $sth->finish(); $dbh->disconnect();
I have installed Active Perl in MSSQL server from where I am running this script. I also created the ODBC System DSN (LocalServer) with following attributes:--
1) Server used is local
2) SQL server verifies authentication with WINDOWS NT login
3) Default database is registry which I am querying.

Please advise, what I am doing wrong??

-Thanks

P.S. :-- This is not the actual SQL query which I am trying ot run but I am getting the same error in this one too. Although from using the query analyzer both the queries run just fine.

Replies are listed 'Best First'.
Re: DBI error Can't locate object method "fetchrow_array"
by logie17 (Friar) on Aug 03, 2009 at 17:56 UTC
    It appears the following line is the problem:

    while (@row = sth->fetchrow_array)

    Should be:

    while (@row = $sth->fetchrow_array)

    s;;5776?12321=10609$d=9409:12100$xx;;s;(\d*);push @_,$1;eg;map{print chr(sqrt($_))."\n"} @_;

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://785515]
Approved by AnomalousMonk
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (5)
As of 2024-04-25 10:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found