I am trying to create a view in mySQL that gets created or updated when a user enters a specific value (woeid). I’ve tried to do this with the stored procedure below:
DELIMITER $$
CREATE DEFINER=`root`@`%` PROCEDURE `sp_getChildren`(
IN woeid INTEGER(15)
)
BEGIN
CREATE OR REPLACE VIEW `test`.`children`
AS
SELECT *
FROM geoplanet_places gp
WHERE gp.parent_id = woeid;
END
The above, or so I have read, is not possible in the current version of mySQL because a view, within a stored routine, cannot refer to routine parameters or local variables. My question would be what the reason for this is, and if there are any effective alternatives. I don’t really want to create a new table and have the procedure update said table.
Any help would be much appreciated, thanks.
Try to use prepared statements –