MySQL Forums
Forum List  »  Stored Procedures

Can you pass in column and table names as parameters?
Posted by: Otis Doss
Date: August 22, 2013 09:47AM

Can you pass in the name of a column or the name of a table as a parameter to a stored procedure (so that the procedure could be used for different tables)? I.e. can you do something like the below where the column name is passed in via the parameter "colname"? BTW Not surprisingly the below does not work; I tried it:


DELIMITER $$
CREATE PROCEDURE abc (IN colname VARCHAR(32), OUT row_count INT)
BEGIN
SELECT COUNT(t1.colname) INTO row_count FROM my_table AS t1;
END $$
DELIMITER ;


Thanks times infinity,
Bill



Edited 1 time(s). Last edit at 08/22/2013 09:50AM by Otis Doss.

Options: ReplyQuote


Subject
Views
Written By
Posted
Can you pass in column and table names as parameters?
4747
August 22, 2013 09:47AM


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.