MySQL Forums
Forum List  »  PHP

Call a STORED PROCEDURE from PHP -> PROCEDURE can't return a result set in the given context
Posted by: Timothy Parez
Date: December 08, 2006 04:59AM

Hi,

I've been searching how to fix this for some time now, but I can't figure it out.

I have the following Stored Procedure:

DELIMITER //
CREATE PROCEDURE GETENTRIES(IN StartIndex INT)
BEGIN
SET @Offset = CONCAT(StartIndex);
SELECT @CurrentId:=MAX(Id) FROM SCREENSHOT;
DROP TABLE IF EXISTS tbl_temp1;
CREATE TEMPORARY TABLE tbl_temp1 (Id INT);
PREPARE STMT FROM "INSERT INTO tbl_temp1 SELECT Id FROM ENTRY WHERE ScreenshotId = @CurrentId ORDER BY Id LIMIT ?";
EXECUTE STMT USING @Offset;
CREATE TEMPORARY TABLE tbl_result (Nickname VARCHAR(100),Tekst VARCHAR(255));
INSERT INTO tbl_result SELECT Nickname, Tekst FROM ENTRY 
WHERE ScreenshotId = @CurrentId AND Id NOT IN (SELECT Id FROM tbl_temp1) LIMIT 10;
END //

Calling this query from the mysql command line works fine.

When I try to call it from php

$selectQuery = "CALL GETENTRIES(6)";
mysql_query($selectQuery)
 or die (mysql_error());

Gives me: PROCEDURE databasename.GETENTRIES can't return
a result set in the given context.

I tried using mysql_unbuffered_query as well.

How can I solve this?

Options: ReplyQuote




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.