in reply to problem calling MySQL stored proc

I don't know if it's related to your specific problem, but it says here that there is a bug in DBD::MySQL that
won't allow you to set 'mysql_multi_results=1', therefore producing the "can't return a result set in the given context" error.
The code below works for me using DBD::mysql 4.005, MySQL Server version: 5.0.37 Source distribution, Linux 2.6.9.
DELIMITER // CREATE DATABASE m5 // USE m5 CREATE PROCEDURE proc4 () BEGIN CREATE TEMPORARY TABLE t4 (ID INTEGER PRIMARY KEY, VALUE INTEG +ER NOT NULL); CREATE TEMPORARY TABLE t5 (ID INTEGER PRIMARY KEY, VALUE INTEG +ER NOT NULL); INSERT INTO t4 VALUES(1,4); INSERT INTO t4 VALUES(2,5); INSERT INTO t4 VALUES(3,6); INSERT INTO t5 VALUES(1,7); INSERT INTO t5 VALUES(2,8); INSERT INTO t5 VALUES(3,9); SELECT DISTINCT t4.ID as ONE, t4.VALUE as TWO, t5.VALUE as THREE FRO +M t4, t5 WHERE t4.ID=t5.ID; END; //
use strict; use warnings; use DBI; use Data::Dumper; my $dbd = "mysql"; my $host = "localhost"; my $db_name = "m5"; my $user = "foo"; my $password = "bar"; my $dsn = "DBI:$dbd:$db_name:$host"; my $dbh = undef; sub open_db_conn { $dbh = DBI->connect( $dsn, $user, $password, { RaiseError => 1, Auto +Commit => 0 } ); print "Could not open database connection: $@" if $@; } sub call_proc4 { my $sth = $dbh->prepare( qq{ call proc4() } ) or die(q{prepare failed!}); $sth->execute() or die(q{execute failed!}); while (my $href = $sth->fetchrow_hashref()) { print Dumper($href); } $sth->finish(); } # ------ main ------ open_db_conn(); my @active_homes = call_proc4(); $dbh->disconnect(); __END__ $ perl 621223.pl $VAR1 = { 'TWO' => '4', 'THREE' => '7', 'ONE' => '1' }; $VAR1 = { 'TWO' => '5', 'THREE' => '8', 'ONE' => '2' }; $VAR1 = { 'TWO' => '6', 'THREE' => '9', 'ONE' => '3' };
--
print map{chr}unpack(q{A3}x24,q{074117115116032097110111116104101114032080101114108032104097099107101114})