labtech
Database
Tables
(current)
Columns
Constraints
Relationships
Orphan Tables
Anomalies
Routines
sp_SplitSetToTempTable
Parameters
Name
Type
Mode
toSplit
text
IN
outputTable
varchar(50)
IN
Definition
BEGIN SET @sql := CONCAT('DROP TEMPORARY TABLE IF EXISTS ', outputTable); PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt; # Creating table SET @sql := CONCAT('CREATE TEMPORARY TABLE ', outputTable, ' (`myKey` INT,INDEX tpk(`myKey`)) ENGINE=MEMORY;'); PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt; IF toSplit IS NOT NULL THEN # Preparing toSplit SET @vars := toSplit; SET @vars := CONCAT("('", REPLACE(@vars, ",", "'),('"), "')"); # Inserting values SET @sql := CONCAT('INSERT IGNORE INTO ', outputTable, ' VALUES ', @vars); PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt; END IF; END