MySQL Forums
Forum List  »  Stored Procedures

Re: table name as stored procedure parameter
Posted by: William Chiquito
Date: October 08, 2007 01:08PM

Hi shaun,

Try:
DELIMITER $$

DROP PROCEDURE IF EXISTS `eduplan`.`GetStakeholder`$$

CREATE PROCEDURE `eduplan`.`GetStakeholder`(usingtable varchar(255), usingid varchar(255), identifier varchar(255))
BEGIN
SET @qry = CONCAT('SELECT * FROM ', usingtable, ' WHERE ', usingid,' = ?');
PREPARE stmt1 FROM @qry;
SET @c = identifier;
EXECUTE stmt1 USING @c;
DEALLOCATE PREPARE stmt1;
END$$

DELIMITER ;

Options: ReplyQuote


Subject
Views
Written By
Posted
Re: table name as stored procedure parameter
10355
October 08, 2007 01:08PM


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.