mysql过程语法失败

时间:2012-08-26 10:04:05

标签: mysql

我的第一个MySQL程序出了问题。我找不到语法失败。这是程序的主体:

DECLARE TerminId INT;

INSERT INTO `Termin` (`Beginn`, `Ende`, `Titel`, `Ganztaegig`, `Serie`, 
                      `Bemerkung`, `Tooltip`, `Ort`, `Gruppe`, `UserId`) 
VALUES (BeginnPara, EndePara, TitelPara, GanztaegigPara, SeriePara, 
        BemerkungPara, TooltipPara, OrtPara, GruppePara, UserIdPara);

SET TerminId = ( SELECT Distinct Id FROM Termin 
                 where Beginn = BeginnPara 
                       and Ende = EndePara 
                       and UserId = UserIdPara);

2 个答案:

答案 0 :(得分:1)

删除简单引用

  DECLARE TerminId INT;

    INSERT INTO Termin(Beginn, Ende, Titel, Ganztaegig, Serie, Bemerkung, Tooltip, Ort, Gruppe, UserId) VALUES (BeginnPara, EndePara, TitelPara, GanztaegigPara, SeriePara, BemerkungPara, TooltipPara, OrtPara, GruppePara, UserIdPara);

    SET TerminId= (SELECT Distinct Id FROM Termin where Beginn = BeginnPara and Ende = EndePara and UserId = UserIdPara having row_number <= 1);

答案 1 :(得分:0)

尝试:

DECLARE TerminId INT;
INSERT INTO `Termin`(`Beginn`, `Ende`, `Titel`, `Ganztaegig`, `Serie`, `Bemerkung`, `Tooltip`, `Ort`, `Gruppe`, `UserId`) VALUES (BeginnPara, EndePara, TitelPara, GanztaegigPara, SeriePara, BemerkungPara, TooltipPara, OrtPara, GruppePara, UserIdPara);

SELECT Distinct Id INTO TerminId FROM Termin where Beginn = BeginnPara and Ende = EndePara and UserId = UserIdPara having row_number <= 1);

问候。