Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- Router
- 검색
- angular route
- Ionic modal
- formgroup
- 스크롤 이벤트 감지
- angular button
- Angular Router
- scroll
- flex-1
- prisma
- 호버
- route
- 셀렉트박스 커스텀
- angular modal
- TAILWIND
- modal
- ajax 사용 예시
- Oracle LISTAGG 사용 예시
- 아이오닉 스크롤 이벤트
- 앵귤러 모달
- mysql if
- 스크롤 이벤트
- summary
- 앵귤러 애니메이션
- egov spring ajax 사용 예시
- ApexChart
- 옵저버블
- angular animation
- 모달
Archives
- Today
- Total
깜놀하는 해므찌로
MyBtis foreach / selectKey 활용 예시 본문
반응형
SMALL
MyBtis 반복문 foreach / selectKey
<!-- 엑셀 업로드 시 기존 레코드 삭제 -->
<update id="deleteContents" parameterType="stcVO">
/* Stc.deleteContents */
<![CDATA[
DELETE
FROM t_stc
]]>
</update>
1. 엑셀 업로드 시 중복 값을 제거하기 위해 일괄 삭제 처리
<insert id="excelInsertContents" parameterType="stcVO">
<selectKey resultType="String" keyProperty="totalSeq" order="BEFORE">
SELECT IFNULL(MAX(TS.SEQ)+1,1) FROM t_stc TS
</selectKey>
INSERT INTO t_stc(
SEQ
, COM
, AREA
, ADDRESS
, VISIT_DATE
)
VALUES
<foreach item="item" index="index" collection="excelList" separator=" , ">
(
#{totalSeq} + #{index}
, #{item.com}
, #{item.area}
, #{item.address}
, STR_TO_DATE(REGEXP_REPLACE(#{item.visitDate},'[^0-9]',''),'%Y%m%d')
)
</foreach>
</insert>
2. selectKey 활용하여 조회된 결과 값을 keyProperty 변수에 저장
3. foreach 활용
- item : 반복문 안에서 활용할 요소의 변수명
- collection : 반복할 리스트 혹은 배열 타입
- separator : 데이터를 구분할 구분자
반응형
LIST
'IT' 카테고리의 다른 글
JavaScript checkbox 자바스크립트 체크박스 (0) | 2022.07.04 |
---|---|
JavaScript Modal 모달창 열기 구현 (0) | 2022.07.04 |
@PathVariable 조건 다중 입력 값 설정 || (0) | 2022.07.04 |
HeidiSQL 하이디 SQL ROOT 권한 (0) | 2022.07.04 |
MySql Sum & IF 활용 (0) | 2022.07.04 |