I am trying to write a stored procedure to create a temporary table with variable columns created based on the linked data of 2 tables. I get the variable fields to be added to the temp table using a query in cursor and I try to add the fields to the temp table using this loop:
OPEN acc_data_fields;
PREPARE stmt FROM 'ALTER TABLE `test`.`tmp_123` ADD COLUMN `?` VARCHAR(255) AFTER `?`';
add_tagheads: LOOP
FETCH acc_data_fields INTO field_tmp;
IF exit_flag = 1 THEN
LEAVE add_tagheads;
END IF;
EXECUTE stmt USING @field_tmp, @add_after;
SET @add_after = @field_tmp;
END LOOP add_tagheads;
DEALLOCATE PREPARE stmt;
CLOSE acc_data_fields;
The Stored proc fails at EXECUTE with the error
Sql Error 1210 Incorrect Arguments to EXECUTE
I read through similar posts but not able to figure out what's wrong. The DB is Mysql 5.1. Any suggestions guys?
Aucun commentaire:
Enregistrer un commentaire