MySQL Forums
Forum List  »  Perl

Using a view to retrieve data through DBD::mysql
Posted by: Jeff
Date: January 25, 2006 05:20PM

Howdy,

I was wondering if anyone would know how to use a view that is in MySQL 5.0.18 in a perl script? I used the standard code using a a SELECT statement in the script:

$dbh = DBI->connect("DBI:mysql:$database:$hostname:$port",$username, $password) or
die "Cannot Connect to the Database: $DBI::errstr.\n";

$sql = qq~SELECT id, name, email_address, phone FROM ${database}.trainers_view ORDER BY id~;

$sth = $dbh->prepare($sql) or die "Cannot Prepare the SQL Statement: $DBI::errstr.\n";
$sth->execute() or die "Cannot Execute the SQL Statement: $DBI::errstr.\n";

And recieve the following error:
DBD::mysql::st execute failed: Table 'evals.trainers_view' doesn't exist at test_views.pl line 21.
at test_views.pl line 21
Cannot Execute the SQL Statement: Table 'evals.trainers_view' doesn't exist.
at test_views.pl line 21


Any thoughts or ideas would be greatly appreciated.
Thanx, Jeff.

PS - When I subsitute a real table name it works fine.

Options: ReplyQuote


Subject
Written By
Posted
Using a view to retrieve data through DBD::mysql
January 25, 2006 05:20PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.