将SQL存储过程转换为MYSQL

时间:2017-11-21 16:22:26

标签: mysql sql sql-server stored-procedures

我有一个用SQL server编写的存储过程。从那以后我迁移到MySQL,我在这个程序中的语法差异遇到了麻烦。谁能帮我?我承认这是在SQL服务器上工作,我已经开始尝试将其转换为MYSQL ...

CREATE PROCEDURE POPPER

    (out StartDate datetime , 
    out EndDate datetime , 
    out USER CHAR(50) ,
    out PLACE Decimal(10,0),
    out PERIODPLAN Decimal(4,0), 
    out PERIOD Decimal(10,0) ,
    out BASE Decimal(6,2))


BEGIN


DELETE From DATES.PERIODFULL
WHERE
PERHOTID = PLACE AND
PERID = PERIOD AND
PERYEAR = PERIODPLAN;


DELETE From DATES.PERIODFULL
WHERE
PERDTE is NULL; 

WITH cte AS (
    SELECT StartDate AS myDate
    UNION ALL
    SELECT DATE_ADD(myDate, INTERVAL 1 day) as myDate
    FROM cte
    WHERE DATE_ADD(myDate, INTERVAL 1 day) <=  EndDate
)

Insert into DATES.PERIODFULL
(USR1, PERHOTID, PERYEAR, PERID, PERDTE, PERBAS)
SELECT USER, PLACE, PERIODPLAN, PERIOD, myDate, BASE
FROM cte
OPTION (MAXRECURSION 0);

END

0 个答案:

没有答案