Skip navigation links

MySQL Forums :: Stored Procedures :: table name as stored procedure parameter


Advanced Search

table name as stored procedure parameter
Posted by: shaun merifield ()
Date: October 08, 2007 09:00AM

I realise this topic has probably been done to death but I cant seem to find a solution which works for me.

I want to call a stored procedure thus: call GetStakeholder("tablename", "unique_identifier", id);

I then want the procedure to return all records from the specified table using the unique identifier with the specified id.

It wont work. I realise this may require prepared statements but they dont seem to do it either.

Can someone post a working example of the syntax to get this working please. So far I *think* it should follow this format:

DELIMITER $$

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

CREATE PROCEDURE `eduplan`.`GetStakeholder`(usingtable varchar(255), usingid varchar(255), identifier varchar(255))
/*LANGUAGE SQL
| [NOT] DETERMINISTIC
| { CONTAINS SQL | NO SQL | READS SQL DATA | MODIFIES SQL DATA }
| SQL SECURITY { DEFINER | INVOKER }
| COMMENT 'string'*/
BEGIN

SELECT
*
FROM
usingtable
WHERE
usingid = identifier
LIMIT 1;


END$$

DELIMITER ;

Cheers!

Options: ReplyQuote


Subject Views Written By Posted
table name as stored procedure parameter 13600 shaun merifield 10/08/2007 09:00AM
Re: table name as stored procedure parameter 5241 Peter Brawley 10/08/2007 11:01AM
Re: table name as stored procedure parameter 5169 shaun merifield 10/08/2007 11:16AM
Re: table name as stored procedure parameter 9083 William Chiquito 10/08/2007 01:08PM
Re: table name as stored procedure parameter 4474 shaun merifield 10/08/2007 02:05PM
Re: table name as stored procedure parameter 3643 shaun merifield 10/08/2007 11:38AM
Re: table name as stored procedure parameter 3710 William Chiquito 10/08/2007 01:05PM


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.