在mysqladmin中创建存储过程? [英] Create stored procedure in mysqladmin?

查看:139
本文介绍了在mysqladmin中创建存储过程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在mysql admin中创建存储过程.我在POWWEB.com上托管一个网站.为此,我试图在mysqladmin中创建存储过程.

I am trying to create stored procedure in mysql admin. I am hosting a website in POWWEB.com. For this purpose i am trying to create stored procedure in mysqladmin.

Mysql版本为5.0.45.我能够只用1行代码创建一个存储过程.

The Mysql version is 5.0.45. I am able to create a stored procedure with only 1 line of code.

CREATE PROCEDURE TEST(input INT)
    INSERT INTO TEST(COL1) VALUES(input);

但这没用.我想编写一个包含更多命令的存储过程.所以我尝试像

But this is of no use. I want to write a stored procedure with more commands. So i try doing like

CREATE PROCEDURE TEST(input INT)
BEGIN
    INSERT INTO TEST(COL1) VALUES(input);
    INSERT INTO TEST1(COL1) VALUES(input);
    INSERT INTO TEST2(COL1) VALUES(input);
END

但是这给出了语法错误.但是相同的代码在我的本地计算机上也可以正常工作. 如果您对解决此问题有任何想法,请告诉我.任何帮助或建议,我们将不胜感激.

But this gives a syntax error. But the same code works fine in my local machine. Please let me know if you have any idea of how to solve this. Any help or advice is greatly appreciated.

推荐答案

默认分隔符为;,因此它将代码解释为多个查询,这显然不起作用.尝试这样的事情:

The default delimiter is ;, so it interprets the code as multiple queries, which obviously doesn't work. Try something like this:

delimiter //
CREATE PROCEDURE TEST(input INT)
BEGIN
    INSERT INTO TEST(COL1) VALUES(input);
    INSERT INTO TEST1(COL1) VALUES(input);
    INSERT INTO TEST2(COL1) VALUES(input);
END//

这篇关于在mysqladmin中创建存储过程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆