Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can't locate object method "NAME" via package "DBI::st"?

Status
Not open for further replies.

JohnnyBgood

IS-IT--Management
Mar 22, 2002
3
US
I'm not even sure what this means. Its seems to be in reponse to the line:

my @variable = @{$sth->NAME};

This is after I have connected to the mySQL database and defined a table, etc. Is this a problem with my DBI mod, or is it just me?
 
This portion of that statement [red]$sth->NAME[/red] is trying to use a method called 'NAME' in the associated DBD::some_flavor module.

Make sure you are spelling and capitalizing the method name correctly.

How are you creating your statement handle?
Can you show us the connect and prepare statements? It sounds like you might not have successfully created the statement handle.

If you are new to Tek-Tips, please use descriptive titles, check the FAQs,
and beware the evil typo.
 
Here are my connect and prepare statements below. As for creating my statement handle, I'm so new to Perl that I'm not sure what that means, precisely. I'm basically stumbling my way through this script based from my Oreily's book.

Appreciate the help.... Thanks...
============
# connect to the database

my $dbh = DBI->connect("DBI:mysql:$db:$server", "$username", "$pw", {RaiseError => 1}) or die("Couldn't connect");

# retreive the table data

my $table_data = $dbh->prepare("select * from newsletters") or die("Couldn't find the TABLE!");
$table_data->execute;
 
A "statement handle" is a DBI term - when you "prepare" some sql, the prepare produces a statement handle - then you can use that statement handle to "execute" the sql. In your example above, your statement handle is $table_data.

It would help if you could post more info:
* what OS/platform are you on
* what versions of perl, DBI, and DBD::mysql do you
have installed
* what is the exact error message you are getting
Hardy Merrill
Mission Critical Linux, Inc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top