Paste Description for Creating Automatic MySQL stored
I am able to output the code via a function or call and a select to create a custom stored procedure. Mysql does not allow a stored proc to create another stored proc. So I must resort to PHP or the command line. Command line would be very convenient.
I have successfully piped the results of mysql commands into another mysql console. For instance creating a select statement which then is piped to mysql and performs the select just created.
However when I try to do the same with a create procedure statement I get the messages listed. If I remove all the \n's and just use spaces, it appears to run fine but the stored proc is not created. an error.
What is pasted her is the stored proc and the sample code.
- Creating Automatic MySQL stored
- Wednesday, July 11th, 2007 at 10:32:33am MDT
- DELIMITER $$
- DROP PROCEDURE IF EXISTS `t1`$$
- CREATE PROCEDURE `t1`()
- BEGIN
- SELECT "
- DELIMITER $$
- DROP PROCEDURE IF EXISTS `t2`$$
- CREATE PROCEDURE `t2`()
- BEGIN
- select * from customer limit 1;
- END$$
- DELIMITER ;
- ";
- END$$
- DELIMITER ;
- user@host:~$ mysql -B --skip-column-names -ppassword -e "CALL t1()" dbname
- \n\nDELIMITER $$\n\nDROP PROCEDURE IF EXISTS `t2`$$\n\nCREATE PROCEDURE `t2`()\n\nBEGIN\n\nselect * FROM customer LIMIT 1;\n\n\nEND$$\n\nDELIMITER ;\n\n
- user@host:~$ mysql -B --skip-column-names -ppassword -e "CALL t1()" dbname |mysql -ppassword dbname
- PAGER SET TO stdout
- PAGER SET TO stdout
- PAGER SET TO stdout
- PAGER SET TO stdout
- PAGER SET TO stdout
- PAGER SET TO stdout
- PAGER SET TO stdout
- PAGER SET TO stdout
- PAGER SET TO stdout
- PAGER SET TO stdout
- user@host:~$
advertising
Update the Post
Either update this post and resubmit it with changes, or make a new post.
You may also comment on this post.
Please note that information posted here will expire by default in one month. If you do not want it to expire, please set the expiry time above. If it is set to expire, web search engines will not be allowed to index it prior to it expiring. Items that are not marked to expire will be indexable by search engines. Be careful with your passwords. All illegal activities will be reported and any information will be handed over to the authorities, so be good.