简体   繁体   English

无法创建存储过程

[英]Cannot create stored procedure

I have the following piece of statement entered into MySQL5.6 Command Line Client. 我在MySQL5.6 Command Line Client中输入了以下语句。 However, the following error was received. 但是,收到以下错误。 I haven't even been able to add in END// Delimiter; 我什至无法添加END //分隔符; after the select statement. 在select语句之后。

At the same time, i was wondering after the stored procedure has been created successfully, how do i CALL the stored procedure without the command line but using java codes. 同时,我想知道存储过程创建成功之后,如何在不使用命令行但使用Java代码的情况下调用存储过程。

Kindly assist. 请协助。 Greatly appreciated! 不胜感激!

错误

give space between delimiter and // . delimiter//之间delimiter空格。 After your select statement write end; select语句写完end; on next line and // at last line (after end; in next new line) 上下一行和//在最后一行(后end;在下一个新行)

delimiter //
create procedure GetUStocks()
Begin
Select * From buystocks;
end;
//

You need a space between DELIMITER and the symbol you are changing the delimiter to. 在DELIMITER和要将定界符更改为的符号之间需要有一个空格。

mysql> DELIMITER //

The clue that it worked should be that you get another mysql> prompt instead of the "unfinished command" prompt -> . 它起作用的线索应该是您得到另一个mysql>提示符,而不是“未完成的命令”提示符->


Re your comment, if you need to call a stored procedure from a Java application, refer to the manual on callable statements: http://dev.mysql.com/doc/refman/5.6/en/connector-j-usagenotes-statements-callable.html 重新发表您的评论,如果您需要从Java应用程序调用存储过程,请参阅可调用语句手册: http : //dev.mysql.com/doc/refman/5.6/en/connector-j-usagenotes-statements -callable.html

mysql> delimiter //

mysql> CREATE PROCEDURE GetUStocke()
-> BEGIN
->   SELECT * FROM buystocks ;
-> END//

Well, seriously, I was Shocked and still am upon this accidental discovery. 好吧,说真的,我很震惊,仍然在这个偶然的发现中。 It's simply because you are not using the delimiter that you have defined for ending the procedure. 仅仅是因为您没有使用为结束过程而定义的定界符。 Here let me attach two snippets that will help illustrate what is generating the error. 在这里,我附上两个片段,这些片段将有助于说明产生此错误的原因。

截图

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM