DECLARE table_name VARCHAR(50);
DECLARE table_pre VARCHAR(20);
DECLARE table_mid VARCHAR(10);
DECLARE table_end VARCHAR(30);
DECLARE sql_text VARCHAR(2000);
DECLARE i INT;
DECLARE j INT;
DECLARE k INT;
SET table_name='';
SET table_pre='tbl_';
SET table_mid='_';
SET table_end='_measurementdata';
SET sql_text='';
SET i=1;
SET j=1;
SET k=1;
SET table_name=CONCAT(table_pre,i,table_mid,j,table_mid,k,table_end);
SET sql_text=CONCAT('CREATE TABLE ', table_name, '(
DataID int(11) NOT NULL AUTO_INCREMENT,
DataValue decimal(10,3) NULL,
MeaFileID int(11) NULL,
NominalID int(11) NULL,
PRIMARY KEY (DataID)
) ' );
SELECT sql_text;
SET @sql_text=sql_text;
PREPARE stmt FROM @sql_text;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
END
各位大神,想把i,j,k换成输入参数,该怎么改呢?今天刚开始学习存储过程,先感谢各位。