DELIMITER $$ CREATE DEFINER=`root`@`localhost` PROCEDURE `profile`(IN `db_profile` VARCHAR(64) CHARSET utf8, IN `dir_profile` VARCHAR(256) CHARSET utf8) BEGIN SET @cnt_num_profile = 0; SET @cnt_tot_profile = 0; /* create temporary table*/ EXECUTE IMMEDIATE CONCAT('DROP TABLE IF EXISTS _tmp'); EXECUTE IMMEDIATE CONCAT( 'CREATE TABLE _tmp ( id BIGINT NOT NULL AUTO_INCREMENT, name VARCHAR(64) NULL, PRIMARY KEY (Id) ) ENGINE = InnoDB'); /*get tables in database*/ INSERT INTO _tmp (name) SELECT TABLE_NAME FROM information_schema.TABLES WHERE TABLE_SCHEMA=db_profile; /*get total number of tables*/ SELECT COUNT(*) INTO @cnt_tot_profile FROM _tmp; WHILE @cnt_num_profile < @cnt_tot_profile DO SET @cnt_num_profile = @cnt_num_profile+1; /* get table name*/ SELECT name INTO @table_name FROM _tmp WHERE id=@cnt_num_profile; /* call procedures */ CALL `duplicates`(db_profile, @table_name, dir_profile); CALL `content`(db_profile, @table_name, dir_profile); CALL `structure`(db_profile, @table_name, dir_profile); END WHILE; EXECUTE IMMEDIATE CONCAT('DROP TABLE IF EXISTS _tmp'); END$$ DELIMITER ;