I am trying to access MySQL stored procedures from a perl script but I receive this error:
"can't return a result set in the given context"
As you can see, the procedure below returns two tables of results. Initially, I thought that the problem was a result of this, but the same error occurs if I call stored procs that have only one select statement.
Here is the proc:
DELIMITER $$
CREATE DEFINER=`root`@`localhost` PROCEDURE `GetPictureDataForSendMsg`(memIdVal VARCHAR(4))
begin
select val, size3
from members
where memid=memIdVal;
select id, filename, picname, picsize
from pictures
where memid=memIdVal order by id asc;
end
Which is called by:
$input = 'ABC1';
$dbh = DBI->connect("DBI:mysql:$db:$server;mysql_multi_statements=true", "$user", "$password");
my $result = $dbh->prepare('CALL GetPictureDataForSendMsg($input)') or error($q, "Problem with database call");
$result->execute or error($q, "Problem with database call");
The error is linked to the execute statement. I have the necessary privileges and the newest version of MySQL; the procedure runs perfectly in the command line.
What's wrong? Thanks for your help.