Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
165 views
in Technique[技术] by (71.8m points)

MYSQL Stored Procedures on Adminer

I'm new to SPs and using Adminer

SET @startDate = initDate;
SET @startTime = initTime;

My stored proc begins like this but throws an error when there is more that one line. initDate and initTime are input vars

It looks like some sort of issue with the delimiter as if both assignments go on one line with a , separator the error shifts further in to the SP.

Error message Syntax error near 'SET @startTime = initTime' at line 4 13:32:48

Would appreciate any tips

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Normally when defining a stored procedure, you re-define the delimiter beforehand:

DELIMITER $$

CREATE PROCEDURE . . .
BEGIN 
    SET @startDate = initDate;
    SET @startTime = initTime;
    . . .
END$$

DELIMITER ;

It does sound like you might have a problem with the delimiter. I also advise you to wrap the body in BEGIN/END.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...