티스토리 뷰

Skill/spring

[mybatis] for문 사용하기

진열사랑 2020. 7. 9. 21:33
	<insert id="coltFcltyNightDao.saveFcltyMoveMinValu" parameterType="Map">
		/* 블럭 이동평균 야간최소유량 저장 : coltFcltyNightDao.saveFcltyMoveMinValu */
		<foreach collection="param" item="item" open="BEGIN" close="END;">
		for i in
		(
		    SELECT 
		    AVG( CASE WHEN fcl.in_se_cd = 'I' THEN (CASE WHEN NVL(fcl.calc_type, '+') = '+' THEN flux.valu else -flux.valu END) END ) minval
		    , min(flux.colt_dt) + 2/1440 mintime -- 시간간격에 따라 시간 달라질수 있음
		    , sec.fclty_cd fcd
		    FROM if_colt_flux flux, cm_fclty_tag fcl, CM_FCLTY sec
		    WHERE flux.tag_sn = fcl.tag_sn
		    AND fcl.fclty_cd = sec.FCLTY_CD
		    and sec.fclty_se_cd = 'BL'
		    and sec.fclty_cd = #{item.fcltyCd}
		    AND flux.colt_dt BETWEEN TO_DATE (#{item.searchStartDt}, 'yyyymmddhh24mi') AND TO_DATE (#{item.searchEndDt}, 'yyyymmddhh24mi')
		    AND flux.valu &gt;= 0
		    group by sec.fclty_cd 
		) 
		loop
		    update if_fclty_night 
		    set move_min_time = i.mintime
		    , move_min_valu = i.minval
		    , updt_id = #{item.loginId}
		    , updt_dt = sysdate
		    where
		    fclty_cd = i.fcd
		    and colt_dt = to_date(SUBSTR(#{item.coltDt},1,8),'yyyymmdd')
		    and nvl(move_min_valu,i.minval) &gt;= i.minval;
		end loop;
		</foreach>
	</insert>
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/12   »
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31
글 보관함