Breaking News
Loading...
22/12/2013

MySQL: use foreach() for common_schema framework

foreach(): Invoke a script on each element of given collection. $() is a synonym of this routine.

Select multiple columns; execute multiple queries based on those columns:
mysql> call foreach(
 "SELECT Code, Name FROM world.Country WHERE Continent='Europe'", 
 "DELETE FROM world.CountryLanguage WHERE CountryCode = '${1}'; 
 DELETE FROM world.City WHERE CountryCode = '${1}'; 
 DELETE FROM Country WHERE Code = '${1}'; 
 INSERT INTO logs (msg) VALUES ('deleted country: name=${2}');");
I think this is the same as cursor

0 comments:

Post a Comment

 
Toggle Footer