DELIMITER $$ DROP PROCEDURE IF EXISTS `updateLocations`$$ CREATE DEFINER=`root`@`localhost` PROCEDURE `updateLocations`(IN localdb VARCHAR(50), IN centraldb VARCHAR(50)) BEGIN SET @getStmnt = CONCAT( 'insert into ',localdb,'.updateloc (llocid) select a.locid from ',localdb,'.location a'); PREPARE stmnt1 FROM @getStmnt; EXECUTE stmnt1; DEALLOCATE PREPARE stmnt1; SET @getStmnt = CONCAT( 'update ',localdb,'.updateloc a ,',localdb,'.location b set b.locid = a.locid where (b.locid=a.llocid)'); PREPARE stmnt1 FROM @getStmnt; EXECUTE stmnt1; DEALLOCATE PREPARE stmnt1; SET @getStmnt = CONCAT( 'update ',localdb,'.updateloc a ,',localdb,'.locdes b set b.locid=a.locid where (b.locid=a.llocid)'); PREPARE stmnt1 FROM @getStmnt; EXECUTE stmnt1; DEALLOCATE PREPARE stmnt1; SET @getStmnt = CONCAT( 'update ',localdb,'.updateloc a ,',localdb,'.germplsm b set b.glocn=a.locid where (b.glocn=a.llocid)'); PREPARE stmnt1 FROM @getStmnt; EXECUTE stmnt1; DEALLOCATE PREPARE stmnt1; SET @getStmnt = CONCAT( 'update ',localdb,'.updateloc a ,',localdb,'.names b set b.nlocn=a.locid where (b.nlocn=a.llocid)'); PREPARE stmnt1 FROM @getStmnt; EXECUTE stmnt1; DEALLOCATE PREPARE stmnt1; SET @getStmnt = CONCAT( 'update ',localdb,'.updateloc a ,',localdb,'.atributs b set b.alocn=a.locid where (b.alocn=a.llocid)'); PREPARE stmnt1 FROM @getStmnt; EXECUTE stmnt1; DEALLOCATE PREPARE stmnt1; SET @getStmnt = CONCAT( 'update ',localdb,'.updateloc a ,',localdb,'.location b set b.SNL3ID=a.locid where (b.SNL3ID=a.llocid)'); PREPARE stmnt1 FROM @getStmnt; EXECUTE stmnt1; DEALLOCATE PREPARE stmnt1; SET @getStmnt = CONCAT( 'update ',localdb,'.updateloc a ,',localdb,'.location b set b.SNL2ID=a.locid where (b.SNL2ID=a.llocid)'); PREPARE stmnt1 FROM @getStmnt; EXECUTE stmnt1; DEALLOCATE PREPARE stmnt1; SET @getStmnt = CONCAT( 'update ',localdb,'.updateloc a ,',localdb,'.location b set b.SNL1ID=a.locid where (b.SNL1ID=a.llocid)'); PREPARE stmnt1 FROM @getStmnt; EXECUTE stmnt1; DEALLOCATE PREPARE stmnt1; END$$ DELIMITER ;