JackTheRussel
Programmer
Hi.
I started learn procedures (MySQL) and I have following problem:
I create procedure in mysql prompt:
Now my perl program call's procedure and try to print results, but it's not working:
It should work, but I got errors:
What should I do ?
any ideas ?
I started learn procedures (MySQL) and I have following problem:
I create procedure in mysql prompt:
Code:
CREATE PROCEDURE department_list()
SELECT department_name,location FROM departments;
Now my perl program call's procedure and try to print results, but it's not working:
Code:
#!/usr/bin/perl
use DBI;
my $dbh = DBI->connect( "DBI:mysql:database:localhost:3306",
"root", "password", { AutoCommit => 0, PrintError => 0, RaiseError => 0 } )
|| die "Connection error: ".$DBI::errstr;
my $sth = $dbh->prepare('call department_list()') || die $DBI::errstr;
$sth->execute || die $DBI::errstr;
while ( my @row = $sth->fetchrow_array ) {
print join("\t",@row),"\n";
}
$sth->finish;
It should work, but I got errors:
Code:
PROCEDURE procedures.department_list can't return a result set in the given context at ./test.pl line 15.
Issuing rollback() for database handle being DESTROY'd without explicit disconnect().
What should I do ?
any ideas ?