MySQL DELIMITER syntax errors

前端 未结 6 861
长发绾君心
长发绾君心 2020-12-06 10:13

This MySQL script installs multiple triggers.

It works on one machine running MySQL 5.0.51b-community. On another machine running MySQL 14.12 Distrib 5.0.45, for re

相关标签:
6条回答
  • 2020-12-06 10:53

    Just as an add-on, for someone else:

    The delimiter is required to enable the entire definition to be passed to the server as a single statement.

    0 讨论(0)
  • 2020-12-06 11:00

    Try the below.

    I am sure it should solve the purpose.

    DELIMITER +
    CREATE TRIGGER STUDENT_INSERT_TRIGGER BEFORE INSERT ON FSL_CONNECTIONS 
    FOR EACH ROW BEGIN 
    INSERT INTO STUDENT_AUDIT 
    SET STUDENT_ID = NEW.STUDENT_ID, 
    MAC_ADDRESS = NEW.MAC_ADDRESS,
    IPADDRESS = NEW.IPADDRESS, 
    EMAIL_ID = NEW.EMAIL_ID , 
    START_TIME=NEW.START_TIME, 
    END_TIME=NEW.END_TIME, 
    STATUS=NEW.STATUS; 
    END; +
    

    From the above when we use a DELIMITER. It should be in the form of

    DELIMITER +
    --
    BLOCK OF SQL WHATEVER YOU WANT TO MENTION
    --
    +
    
    0 讨论(0)
  • 2020-12-06 11:03

    Hmm I'm having similar problems. I do a mysqldump from Debian Lenny running 5.0.51 and try importing to OpenSolaris running 5.0 and get the same error. And I have DELIMITER ;

    Version conflict?

    0 讨论(0)
  • 2020-12-06 11:07

    Try

    DELIMITER ;
    

    not

    DELIMITER;
    

    You're actually specifying ; as an argument to the DELIMITER command, so not having the space there may be confusing it.

    0 讨论(0)
  • 2020-12-06 11:08

    In the version of MySql I use the same error occurs when using the delimiter command, but this version handles the delimiter ";" for statements and delimiter "|" for stored procedures and functions, which i think solves the problem; try this:

    DROP TRIGGER IF EXISTS trigger_name;

    CREATE TRIGGER trigger_name BEFORE UPDATE ON table FOR EACH ROW BEGIN -- Trigger logic goes here END |

    -- other statements or functions here

    0 讨论(0)
  • 2020-12-06 11:12

    You need a space between 'DELIMITER' and ';'

    DELIMITER ;
    # not:
    DELIMITER;
    
    0 讨论(0)
提交回复
热议问题