谁能帮我解决将 MsSQL 转换为 MySQL 的问题?它给出了一个语法错误。
原始 Mssql 函数:
CREATE FUNCTION StrToNum (srt1 varchar(250))
RETURNS real AS
BEGIN
DECLARE t real
IF srt1 IS NOT NULL and ISNUMERIC(srt1)=1 and PATINDEX('%,%',srt1)=0 and
PATINDEX('%e%',srt1)=0
SET t=CONVERT(Money,srt1)
ELSE
SET t=NULL
RETURN t
END
我像mysql一样尝试过
DELIMITER $$
CREATE FUNCTION StrToNum (srt1 VARCHAR(250))
RETURNS REAL DETERMINISTIC
BEGIN
DECLARE t REAL;
IF srt1 IS NOT NULL AND srt1 > 0 AND POSITION('%,%' IN srt1=0) AND POSITION('%e%' IN srt1=0)
THEN SET t=CONVERT(Money,INT);
ELSE
THEN SET t=NULL; END IF;
RETURN t;
END IF;
END $$
DELIMITER;