时间:2021-07-01 10:21:17 帮助过:22人阅读
与vba交互不方便python写,做一个很简单的 有了就更新,没有就插入表的函数。
用的是navicat的工具
参数:
IN yahoo_code varchar(20) , IN begin_date char(10), IN end_date char(10)
函数内容:
BEGIN
DECLARE stockArea VARCHAR(20);
select b.marketName into @stockArea from Instruments a LEFT JOIN Markets b on a.marketId = b.marketId where a.YahooCode=CONVERT(yahoo_code USING utf8) COLLATE utf8_unicode_ci;
#set @stockArea = "China";
set @stockArea =CONCAT("HistPrices",@stockArea);
set @STMT := CONCAT("select a.* from ",@stockArea," a LEFT JOIN Instruments b on a.instrumentId=b.instrumentId where b.YahooCode=CONVERT(‘",yahoo_code,"‘ USING utf8) COLLATE utf8_unicode_ci and a.tradeDate >= ‘",begin_date,"‘ and a.tradeDate <= ‘",end_date,"‘ ");
PREPARE STMT FROM @STMT;
EXECUTE STMT;
END
mysql自定义函数
标签: