sql >> Base de Datos >  >> RDS >> Mysql

Alternativa de vistas dinámicas en mySQL

Intente usar declaraciones preparadas -

CREATE PROCEDURE sp_getChildren(IN woeid INTEGER(15))
BEGIN
  SET @sql = CONCAT('CREATE  OR REPLACE VIEW `test`.`children` AS SELECT * FROM geoplanet_places gp WHERE gp.parent_id = ', woeid);
  PREPARE stmt FROM @sql;
  EXECUTE stmt;
  DEALLOCATE PREPARE stmt;
END