我的查询语句依赖如下函数,如何在代码中定义呢?
DELIMITER $$
CREATE FUNCTION isUpBan
(in_lastclose decimal(15,10),
in_open DECIMAL(15,10),
in_close DECIMAL(15,10),
in_high DECIMAL(15,10),
in_low DECIMAL(15,10))
RETURNS tinyint(1)
BEGIN
DECLARE l_new_string VARCHAR(255);
DECLARE last_close INT;
DECLARE cur_open INT;
DECLARE cur_close INT;
DECLARE cur_high INT;
DECLARE cur_low INT;
DECLARE banUpPrice1 INT;
DECLARE banUpPrice2 INT;
DECLARE ret TINYINT;
SET last_close=in_lastclose*1000/10;
SET cur_open=in_open*1000/10;
SET cur_close=in_close*1000/10;
SET cur_high=in_high*1000/10;
SET cur_low=in_low*1000/10;
set banUpPrice1 = (last_close * 1050 + 500) / 1000;
SET banUpPrice1 = (last_close * 1100 + 500) / 1000;
SET ret=1;
IF (cur_open=cur_high && cur_open=cur_low && cur_open=cur_close && cur_open>last_close) THEN
SET ret=1;
END IF;
IF (cur_close!=cur_high) THEN
SET ret=0;
END IF;
IF (cur_close!=banUpPrice1 && cur_close!=banUpPrice2) THEN
SET ret=0;
END IF;
RETURN(ret);
END$$