简体   繁体   中英

Cannot create stored procedure

I have the following piece of statement entered into MySQL5.6 Command Line Client. However, the following error was received. I haven't even been able to add in END// Delimiter; after the select statement.

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.

Kindly assist. Greatly appreciated!

错误

give space between delimiter and // . After your select statement write end; on next line and // at last line (after end; in next new line)

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

You need a space between DELIMITER and the symbol you are changing the delimiter to.

mysql> DELIMITER //

The clue that it worked should be that you get another mysql> prompt instead of the "unfinished command" prompt -> .


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

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.

截图

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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