Re: Parameters for table, field and searchValue
OK, I think I'm almost there....
Here is my sproc.
PROCEDURE `usp_CheckForValue`(IN p_tbl varchar(50), IN p_fld varchar(50), IN p_searchValue varchar(50))
BEGIN
SET @t = p_tbl;
SET @f = p_fld;
SET @search = p_searchValue;
SET @s = CONCAT("SELECT ", @f, " FROM ", @t, " WHERE ", @f, " = ", @search);
PREPARE stmt FROM @s;
EXECUTE stmt;
END
I am looking up a table called "species" and a field called "speciesID" and looking for "COD"
CALL usp_SearchForValue("Species", "SpeciesID", "COD")
I get error message:
Error Code: 1054. Unknown column 'COD' in 'where clause' 0.000 sec
It's too literal this time !!
Can you advise ?
Thanks.