我有这个存储过程,它应该检查一个字段是否为空并执行一个查询,否则执行另一个,但我得到一个错误。这是代码:
DELIMITER $$
CREATE PROCEDURE mw_info(
m_date_begin INTEGER,
m_date_end INTEGER,
m_from INTEGER,
m_numberOfrecords INTEGER,
m_callsource VARCHAR(15))
BEGIN
IF (m_callsource = '') THEN
SELECT *
FROM mw_iaa
WHERE calllegcode IN ('CB_A','CB_B')
AND calltime BETWEEN m_date_begin AND m_date_end
ORDER BY calltime DESC
LIMIT m_from, m_numberOfrecords;
ELSE
SELECT *
FROM mw_iaa
WHERE calllegcode IN ( 'CB_A', 'CB_B')
AND callsource = m_callsource
AND calltime BETWEEN m_date_begin AND m_date_end
ORDER BY calltime DESC
LIMIT m_from, m_numberOfrecords;
END IF;
END;
END$$
DELIMITER ;
这是错误:
错误代码:1064 您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,以
在第 1 行的“else SELECT * FROM mw_iaa WHERE calllegcode”附近使用正确的语法
问题可能是什么?