Part of Slepp's ProjectsPastebinTURLImagebinFilebin
Feedback -- English French German Japanese
Create Upload Newest Tools Donate
Sign In | Create Account

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 

  1. DELIMITER $$
  2.  
  3. DROP PROCEDURE IF EXISTS `t1`$$
  4. CREATE PROCEDURE `t1`()
  5. BEGIN
  6.  
  7. SELECT "
  8. DELIMITER $$
  9. DROP PROCEDURE IF EXISTS `t2`$$
  10. CREATE PROCEDURE `t2`()
  11. BEGIN
  12. select * from customer limit 1;
  13. END$$
  14. DELIMITER ;
  15. ";
  16.  
  17. END$$
  18. DELIMITER ;
  19.  
  20.  
  21. user@host:~$ mysql -B --skip-column-names -ppassword -e "CALL t1()" dbname
  22. \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
  23.  
  24. user@host:~$ mysql -B --skip-column-names -ppassword -e "CALL t1()" dbname |mysql -ppassword dbname
  25. PAGER SET TO stdout
  26. PAGER SET TO stdout
  27. PAGER SET TO stdout
  28. PAGER SET TO stdout
  29. PAGER SET TO stdout
  30. PAGER SET TO stdout
  31. PAGER SET TO stdout
  32. PAGER SET TO stdout
  33. PAGER SET TO stdout
  34. PAGER SET TO stdout
  35. 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.

update paste below
details of the post (optional)

Note: Only the paste content is required, though the following information can be useful to others.

Save name / title?

(space separated, optional)



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.

fantasy-obligation