py_mybatis icon indicating copy to clipboard operation
py_mybatis copied to clipboard

foreach,后面的内容没有被拼接上;

Open tryinggo opened this issue 4 years ago • 2 comments

image

tryinggo avatar Sep 23 '20 02:09 tryinggo

xml:

IF NOT EXISTS ( SELECT Id from [istrong_data_collection].[dbo].[FY_XjWeather] where StartTime = #{StartTime} ) BEGIN
        IF NOT EXISTS
        (SELECT Id from [istrong_data_collection].[dbo].[FY_XjWeather] where CompanyId = #{SiteCodeList['CompanyId']} and SiteCode = #{SiteCodeList['SiteCode']} and DataTime=#{SiteCodeList['Time']})
        BEGIN
        INSERT INTO [istrong_data_collection].[dbo].[FY_XjWeather]
        ([CompanyId],[SiteCode],[SiteSource],[Rain],[DataTime],[Remark])
        VALUES
        ($f{SiteCodeList['CompanyId']},$f{SiteCodeList['SiteCode']},#{SiteCodeList['SiteSource']},${SiteCodeList['Rain']},$f{SiteCodeList['Time']},#{SiteCodeList['DataSource']})
        END
        </foreach>
    END
</insert>
输出: IF NOT EXISTS ( SELECT Id from [istrong_data_collection].[dbo].[FY_XjWeather] where StartTime = '2020-08-03 13:00:00' ) BEGIN
    IF NOT EXISTS
    (SELECT Id from [istrong_data_collection].[dbo].[FY_XjWeather] where CompanyId = '64' and SiteCode = '58752' and DataTime='2020-08-03 13:00:00')
    BEGIN
    INSERT INTO [istrong_data_collection].[dbo].[FY_XjWeather]
    ([CompanyId],[SiteCode],[SiteSource],[Rain],[DataTime],[Remark])
    VALUES
    ('64','58752','2',1.688,'2020-08-03 13:00:00','测试')
    END

问题: foreach后的END没有拼接上,请教大神,这个是为什么?

tryinggo avatar Sep 23 '20 02:09 tryinggo

完整的xml 发一下,你这个语法不太像sql啊

dushitaoyuan avatar Mar 29 '24 11:03 dushitaoyuan