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:

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

Thanks times infinity,

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

Options: ReplyQuote

Written By
Can you pass in column and table names as parameters?
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.