复制内容到剪贴板
代码:USE test;
DELIMITER //
drop
procedure
if
exists updata
//
CREATE PROCEDURE updata ()
BEGIN
DECLARE v_risePrice decimal(20,8); #涨停价
DECLARE v_fallPrice decimal(20,8); #跌停价
DECLARE v_openPrice decimal(20,8); #开盘价
DECLARE v_contractid bigint;#合约ID
DECLARE v_priceTick decimal(20,8); #最小变动价
DECLARE v_price decimal(20,8);
DECLARE done INT;
Declare updcur CURSOR FOR
SELECT
a.RisePrice,
a.fallprice,
a.openprice,
a.contractid,
b.pricetick,
b.price
FROM qoutdata AS a,contractinfo as b where a.contractid=b.contractid;
#DECLARE CONTINUE HANDLER FOR NOT FOUND SET done=1;
#SET done=0;
Open updcur;
FETCH updcur INTO v_risePrice,v_fallPrice,v_openPrice,v_contractid,v_priceTick,v_price;
WHILE (v_risePrice is not null) DO
IF v_openPrice>=0 THEN
IF (v_risePrice MOD v_priceTick)<>0 THEN
SET v_risePrice=v_risePrice-(v_risePrice MOD v_priceTick);
UPDATE qoutdata SET RisePrice=v_risePrice WHERE contractid=v_contractid;
END IF;
IF (v_fallPrice MOD v_priceTick)<>0 THEN
SET v_fallPrice=v_fallPrice+v_priceTick-(v_fallPrice MOD v_priceTick);
UPDATE qoutdata SET FallPrice=v_fallPrice WHERE contractid=v_contractid;
END IF;
END IF;
FETCH updcur INTO v_risePrice,v_fallPrice,v_openPrice,v_contractid,v_priceTick,v_price;
END WHILE;
CLOSE updcur;
END//
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
如需转载请保留出处:https://bianchenghao.cn/bian-cheng-ji-chu/78557.html