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!

Perl + procedures problem

Status
Not open for further replies.

JackTheRussel

Programmer
Aug 22, 2006
110
FI
Hi.

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;
$dbh->disconnect;
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 ?
 
Jack, sounds like it's a Perl issue and not a MySQL issue? Have you tried posting in the Perl forum, forum219?
 
Need a bit more to go on.

Can you test the procedure on its own using mysql client... then

PROCEDURE procedures.department_list can't return a result set in the given context at ./test.pl line 15.
.. which line of code is line 15

My guess this is nothing to do with this code snippet
Issuing rollback() for database handle being DESTROY'd without explicit disconnect().
 
Hi hvass.

Everything is working fine when I run these procedures in mysql prompt. So the problem is on the perl side.

You are right.
This isn't the real problem:
Code:
issuing rollback() for database handle being DESTROY'd without explicit disconnect().
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top