Reputation: 225
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!
Upvotes: 1
Views: 5212
Reputation: 21
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.
Upvotes: 0
Reputation: 562428
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
Upvotes: 1
Reputation: 1781
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;
//
Upvotes: 3
Reputation: 3484
mysql> delimiter //
mysql> CREATE PROCEDURE GetUStocke()
-> BEGIN
-> SELECT * FROM buystocks ;
-> END//
Upvotes: 2