mysql delimiter error

后端 未结 8 1620
别那么骄傲
别那么骄傲 2020-12-06 16:53

Modifed.

DROP FUNCTION IF EXISTS PersonName;
DELIMITER |;

CREATE FUNCTION PersonName( personID SMALLINT )
RETURNS CHAR(20)
BEGIN
  DECLARE pname CHAR         


        
相关标签:
8条回答
  • 2020-12-06 17:13

    Try this if you are using phpMyAdmin:

    http://dotnetfish.blogspot.com/2009/07/1064-you-have-error-in-your-sql-syntax.html

    0 讨论(0)
  • 2020-12-06 17:15

    Try this:

    DROP FUNCTION IF EXISTS PersonName;
    DELIMITER |
    
    CREATE FUNCTION PersonName( personID SMALLINT )
    RETURNS CHAR(20)
    BEGIN
      DECLARE pname CHAR(20) DEFAULT '';
      SELECT name INTO pname FROM family WHERE ID=personID;
      RETURN pname;
    END;
    |
    DELIMITER ; /* <-- add a space between DELIMITER and the semicolon */
    
    0 讨论(0)
  • 2020-12-06 17:23

    I'm going to throw this in the mix because it may help other people with this issue.

    If you are using phpMyAdmin, below the SQL entry box there is a delimiter box where you can type the delimiter to use for the query. You can put the outside delimiter here if you want to and then you don't need the delimiter directives.

    For example, if you put the delimiter $$ inside the box you could use the following format for your query.

    CREATE FUNCTION
    blah blah...
    END 
    $$
    

    Some people may find this easier.

    0 讨论(0)
  • 2020-12-06 17:24

    Best solution is, which I tried after getting the above error. The code should be like

    Delimiter //
    Create function or procedure
    Write your function or procedure here...
    End (without semicolon)
    //
    Delimiter ; (semicolon with space)
    
    0 讨论(0)
  • 2020-12-06 17:27

    You have to add delimiter $$ in the beginning and in the last of the mysql script you should to end by the delimiter

    0 讨论(0)
  • 2020-12-06 17:30

    I was have problems with the delimiter. I was using Navicat, then I rolled over to MySql workbench and the problem is solved. Workbench inserts the delimiter into code...

    0 讨论(0)
提交回复
热议问题