๋กœ์ผ“๐Ÿพ
article thumbnail

 

<insert id="insertSubject" parameterType="wBMap">
		<selectKey keyProperty="sn" resultType="int" order="BEFORE">
	    	SELECT SBJECT_MASTR_SEQ.NEXTVAL FROM DUAL
		</selectKey>
		INSERT INTO SBJECT_MASTR (SBJECT_MASTR_SN, SBJECT_NM, SBJECT_CODE, SBJECT_CTGRY, EDC_TRGET, SRCHWRD, USE_YN, CM, REGIST_DT, REGIST_MBER_SEQ)
		VALUES (#{sn}, #{sbject_nm}, 'ES'||LPAD(#{sn}, 6, 0), #{sbject_ctgry}, #{edc_trget}, #{srchwrd}, #{use_yn}, #{cm}, SYSDATE, #{mber_seq})
	</insert>

 

์˜ค๋ผํด ๊ธฐ์ค€์˜ ๊ธ€์ž…๋‹ˆ๋‹ค.

 

<selectKey> ํƒœ๊ทธ๋ฅผ ์ด์šฉํ•˜์—ฌ ํ˜„์žฌ ์‹œํ€€์Šค ๋‹ค์Œ์˜ ์‹œํ€€์Šค๋ฅผ ๊ฐ€์ ธ์˜ฌ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

 


ใ…ฃSELECT SBJECT_MASTR_SEQ.NEXTVAL FROM DUAL

 

SBJECT_MASTR์˜ ๋‹ค์Œ ์‹œํ€€์Šค๋ฅผ ๊ฐ€์ ธ์˜ค๊ธฐ ์œ„ํ•จ์ž…๋‹ˆ๋‹ค. mysql์˜ auto increment ์ƒ๊ฐํ•˜๋ฉด ๋ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค. DUAL์€ ์ž„์‹œ ํ…Œ์ด๋ธ”์ž…๋‹ˆ๋‹ค.

๋งŒ์•ฝ ํ˜„์žฌ ์‹œํ€€์Šค๋ฅผ ๊ฐ€์ ธ์˜ค๊ณ  ์‹ถ๋‹ค๋ฉด CURRVAL์„ ์‚ฌ์šฉํ•˜์‹œ๋ฉด ๋ฉ๋‹ˆ๋‹ค.

 

# keyProperty

 

keyProperty๋Š” SELECT SBJECT_MASTR_SEQ.NEXTVAL FROM DUAL ์˜ ๊ฐ’์„ ๋ฐ›๋Š” ๋ณ€์ˆ˜์ž…๋‹ˆ๋‹ค.  ์˜ˆ์ œ ์ฝ”๋“œ์—์„œ๋Š” keyProperty = sn ์ด๋ฏ€๋กœ ๋‹ค์Œ ์ฟผ๋ฆฌ๋ฌธ์—์„œ sn์œผ๋กœ ์‹œํ€€์Šค ๊ฐ’์— ์ ‘๊ทผํ• ์ˆ˜ ์žˆ๊ฒŒ ๋ฉ๋‹ˆ๋‹ค.

 

# order

 

order ๋Š” INSERT ๋ฌธ์„ ์‹คํ–‰ํ•˜๊ธฐ ์ „์— ํ• ๊ฑฐ๋ƒ ํ•œํ›„์— ํ• ๊ฑฐ๋ƒ ๊ฒฐ์ •ํ•ด์ฃผ๋Š” ๊ฒƒ์ธ๋ฐ before ์ด๋ฏ€๋กœ ์ฟผ๋ฆฌ๋ฌธ ์‹คํ–‰์ „์ž…๋‹ˆ๋‹ค. after๋กœ ํ•˜๊ฒŒ๋˜๋ฉด ์ฟผ๋ฆฌ๋ฌธ์„ ์‹คํ–‰ํ›„ ํ•ด๋‹น ์ฟผ๋ฆฌ๋ฅผ ์‹คํ–‰ํ•ฉ๋‹ˆ๋‹ค. 

 

# resultType

resultType์€ ๋ณ€์ˆ˜๋ช…์—์„œ ์•Œ์ˆ˜ ์žˆ๋“ฏ ๋ฐ˜ํ™˜๊ฐ’์˜ ๋ฐ์ดํ„ฐํ˜•์ž…๋‹ˆ๋‹ค.

 

 

 

 

<selectKey> ํƒœ๊ทธ ๋ง๊ณ  ์œ„ ์ด๋ฏธ์ง€์ฒ˜๋Ÿผ VALUES์— ๋ฐ”๋กœ SEQ.NEXTVAL๋ฅผ ํ•ด๋„ ์ƒ๊ด€์—†์Šต๋‹ˆ๋‹ค.

 

 

 

์ฝ์–ด์ฃผ์…”์„œ ๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค.

์งˆ๋ฌธ์€ ์–ธ์ œ๋‚˜ ํ™˜์˜ํ•ฉ๋‹ˆ๋‹ค.

 

"๋‚œ ๋ฐ˜๋“œ์‹œ ๋ฐฑ์—”๋“œ ์™•์ด ๋ ๊ฑฐ์•ผ"

profile on loading

Loading...