header-img
Info :
728x90

 

์ฟผ๋ฆฌ๋ฌธ์„ ์ž‘์„ฑํ•˜๋‹ค๋ณด๋ฉด ๋น„๊ต๋ฌธ์„ ์‚ฌ์šฉํ•˜๋Š” ๊ฒฝ์šฐ๊ฐ€ ์ƒ๊ธฐ๋Š”๋ฐ..

๋งˆ์ด๋ฐ”ํ‹ฐ์Šค์—์„œ๋Š” <,>,<= ๋“ฑ๊ณผ ๊ฐ™์€ ๋ถ€๋“ฑํ˜ธ๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด ์˜ค๋ฅ˜๊ฐ€ ๋ฐœ์ƒํ•œ๋‹ค...

 

๋งˆ์ด๋ฐ”ํ‹ฐ์Šค์—์„œ๋Š” ๋น„๊ต์—ฐ์‚ฐ์ž๋ฅผ ์‚ฌ์šฉํ•  ๊ฒฝ์šฐ

๋น„๊ต ์—ฐ์‚ฐ์ž์ธ์ง€ ๊ด„ํ˜ธ์ธ์ง€ ๊ตฌ๋ถ„์„ ๋ชปํ•ด์„œ Error ๊ฐ€ ๋–จ์–ด์ง„๋‹ค๊ณ  ํ•จ.

 

๋ญ”๊ฐ€ ๋‹ค๋ฅธ ์“ฐ๋Š” ๋ฐฉ๋ฒ•์ด ์žˆ๋Š” ๋“ฏ ํ•˜๋‹ค.

 

๊ทธ "๋‹ค๋ฅธ ์“ฐ๋Š” ๋ฐฉ๋ฒ•"์— ๋Œ€ํ•ด ์•Œ์•„๋ณด์ž.

 

์šฐ์„  ๋‚ด๊ฐ€ ์ž‘์„ฑํ•œ

์ž˜๋ชป๋œ ์ฝ”๋“œ

 

<update id="siteCalendarCreate" parameterType="HashMap">
	WITH CTE(WorkDate) AS (
		SELECT CONVERT ( DATE, #{Year}+'-01-01')
		UNION ALL
		SELECT DATEADD(d, 1, WorkDate)
		FROM CTE
		WHERE  WorkDate < (CONVERT(DATE, #{Year}+'-12-31'))
	)
	SELECT * FROM CTE OPTION ( MAXRECURSION 0 );
</update>

 

 

ํ•ด๊ฒฐ๋ฐฉ๋ฒ• 1. CDATA

 

CDATA ๋กœ ํ•ด๊ฒฐํ•˜๋Š” ๋ฐฉ๋ฒ•์€ ๋‘๊ฐ€์ง€์ด๋‹ค.

 

ํ•˜๋‚˜. <![CDATA["๋ถ€๋“ฑํ˜ธ"]]>

<update id="siteCalendarCreate" parameterType="HashMap">
	WITH CTE(WorkDate) AS (
		SELECT CONVERT ( DATE, #{Year}+'-01-01')
		UNION ALL
		SELECT DATEADD(d, 1, WorkDate)
		FROM CTE
		WHERE  WorkDate <![CDATA["<"]]> (CONVERT(DATE, #{Year}+'-12-31'))
	)
	SELECT * FROM CTE OPTION ( MAXRECURSION 0 );
</update>

 

 

๋‘˜. <![CDATA[์ž˜๋ชป๋œ ์ฟผ๋ฆฌ๋ฌธ]]>

<update id="siteCalendarCreate" parameterType="HashMap">
	WITH CTE(WorkDate) AS (
		SELECT CONVERT ( DATE, #{Year}+'-01-01')
		UNION ALL
		SELECT DATEADD(d, 1, WorkDate)
		FROM CTE
		WHERE <![CDATA[WorkDate < (CONVERT(DATE, #{Year}+'-12-31'))]]>
	)
	SELECT * FROM CTE OPTION ( MAXRECURSION 0 );
</update>

 

 

ํ•ด๊ฒฐ๋ฐฉ๋ฒ• 2. gt, lt

 

๋Œ€์ฒด์‹์„ ์ด์šฉํ•˜์—ฌ ๋ฌธ๋ฒ•์— ๋งž์ถฐ์ฃผ๋Š” ๋ฐฉ๋ฒ•์ด๋‹ค.

<update id="siteCalendarCreate" parameterType="HashMap">
	WITH CTE(WorkDate) AS (
		SELECT CONVERT ( DATE, #{Year}+'-01-01')
		UNION ALL
		SELECT DATEADD(d, 1, WorkDate)
		FROM CTE
		WHERE  WorkDate &lt; (CONVERT(DATE, #{Year}+'-12-31'))
	)
	SELECT * FROM CTE OPTION ( MAXRECURSION 0 );
</update>

 

๊ธฐํ˜ธ ๋Œ€์ฒด์‹ ์˜ˆ์ œ
< lt workDate &lt; '2024-01-01'
> gt workDate &gt; '2024-01-01'

 

when ์ด๋‚˜ if์ ˆ์˜ test์—์„œ ๋ถ€๋“ฑํ˜ธ๋ฅผ ์‚ฌ์šฉํ•˜๊ณ  ์‹ถ๋‹ค๋ฉด

 

๋Œ€์ฒด์‹์„ ์‚ฌ์šฉํ•˜์—ฌ ํ‘œ๊ธฐํ•ด์ฃผ๋ฉด ๋œ๋‹ค.

 

<if test = ' workDt > 2024-01-01 ' > ์˜ ๊ฒฝ์šฐ๋Š” <if test = 'workDt lt 2024-01-01' > ์˜ ํ˜•์‹์œผ๋กœ ์‚ฌ์šฉํ•˜๋ฉด ๋จ.

 

 

 

728x90
๋”๋ณด๊ธฐ
BACKEND