954,560 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Stored Procedure not working

Hi everyone,

Can anyone tell my why this does not work?

I created a stored procedure that uses a variable / input value as table name, but it does not do what it's supposed to do.
Here is the code:

delimiter //
DROP PROCEDURE IF EXISTS userpages.respondtoconnectionrequest//
CREATE DEFINER = 'sithembiso'@'localhost' PROCEDURE userpages.respondtoconnectionrequest(IN tname VARCHAR(23),IN response INT,IN ouserid INT(14),IN fuserid INT(14),IN fftable VARCHAR(23))
BEGIN
	SET @u = CONCAT('UPDATE `userpages`.`',tname,'` SET `status`=',response,' WHERE `',tname,'`.`userID`=',fuserid);
	PREPARE stmtu FROM @u;
	EXECUTE stmtu;
	DEALLOCATE PREPARE stmtu;
	IF (response = 1) THEN
		SET @i = CONCAT('UPDATE `userpages`.`',fftable,'` SET `status`=',response,' WHERE `',fftable,'`.`userID`=',ouserid);
		PREPARE stmti FROM @i;
		EXECUTE stmti;
		DEALLOCATE PREPARE stmti;
	END IF;
END;
//
delimiter ;


If I call this using the following code, it does not update those fields and it does not return any error.

CALL userpages.respondtoconnectionrequest('91031707885__friends',1,'91031707885','43979905046','43979905046__friends');


Any light on this will be highly appreciated.

sithembisophp
Newbie Poster
14 posts since Aug 2010
Reputation Points: 10
Solved Threads: 3
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: