MySQL stored procedure syntax error after BEGIN

后端 未结 1 1846
予麋鹿
予麋鹿 2020-12-21 18:48

I am attempting to recreate a stored procedure (since I can\'t edit the body). I called SHOW CREATE PROCEDURE to use the same format as the original stored procedure but whe

相关标签:
1条回答
  • 2020-12-21 19:06

    You are missing the delimiter definition before and after the stored proc definition:

    If you use the mysql client program to define a stored program containing semicolon characters, a problem arises. By default, mysql itself recognizes the semicolon as a statement delimiter, so you must redefine the delimiter temporarily to cause mysql to pass the entire stored program definition to the server.

    To redefine the mysql delimiter, use the delimiter command. [...] The delimiter is changed to // to enable the entire definition to be passed to the server as a single statement, and then restored to ; before invoking the procedure. This enables the ; delimiter used in the procedure body to be passed through to the server rather than being interpreted by mysql itself.

    Since the stored proc definition and body was ok, syntax chack gave you the thumbs up, but the code would not run properly in your client.

    Use the following skeleton for defining a stored procedure:

    delimiter //
    create procedure ...
    ...
    end
    //
    delimiter ;
    
    0 讨论(0)
提交回复
热议问题