Where I have more than one table in my database for use with (similar, but) different products.
Is it possible to select a table to work with based on a parameter (example below)? (This would save me having multiple similar copies of the same procedure).
Cheers.
DELIMITER $$
DROP PROCEDURE IF EXISTS `dostuff` $$
CREATE PROCEDURE `dostuff`(IN prod_code VARCHAR(10))
BEGIN
IF INSTR(prod_code, 'product_a') THEN
myTable = product_a_table
ELSE IF INSTR(prod_code, 'product_b') THEN
myTable = product_b_table
END IF
-- do stuff on myTable such as SELECT and UPDATE
END $$
DELIMITER ;