깜놀하는 해므찌로

Egov Spring Oracle MyBatis NVL 사용 예시 / Oracle OR 본문

IT

Egov Spring Oracle MyBatis NVL 사용 예시 / Oracle OR

agnusdei1207 2022. 7. 20. 21:15
반응형
SMALL
<sql id="modalWhere">    
    <if test='popSearchCondition != null and popSearchCondition !="" and popSearchCondition ==0'>    
        AND (A.NAME LIKE '%' || #{popSearchKeyword} || '%' OR B.C_CODE_NM LIKE '%' || #{popSearchKeyword} || '%')
    </if>   
    <if test="popSearchCondition !=null and popSearchCondition !='' and popSearchCondition ==1">
        AND A.NAME LIKE '%' || #{popSearchKeyword} || '%'
    </if>
    <if test="popSearchCondition !=null and popSearchCondition !='' and popSearchCondition ==2">
        AND B.C_CODE_NM LIKE '%' || #{popSearchKeyword} || '%'
    </if>      
    <if test="popDivn !=null and popDivn !=''">
        <choose>   
            <when test='popDivn.equals("fvrts")'>     
                AND NVL(C.FVRTS_SEQ, 'N') = 'Y'      
            </when>         
            <when test='popDivn.equals("2,3")'>     
                AND (A.WORK_DIV = '2' OR  A.WORK_DIV = '3')
            </when>      
            <otherwise>                    
                AND A.WORK_DIV LIKE '%' || #{popDivn} || '%'  
            </otherwise>          
        </choose>    
    </if>     
</sql>

1. 검색어, 검색 조건에 따른 Like 함수 활용

2. NVL(널 체크 할 값, 널일 경우 반환할 값)

3. Oracle 경우 or 는 OR 로 표기

 

반응형
LIST