<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">

<mapper namespace="egovframework.service.mapper.UnitSystSttsMapper">

	<insert id="insertUnitSystSttsHs" parameterType="String">
		INSERT INTO TB_UNIT_SYST_STTS_HS(SYST_ID, CRTN_DT, SYST_STTS_CD) 
		                          VALUES('WEB01', TO_CHAR(SYSDATE,'YYYYMMDDHH24MISS'), #{sStatus})
	</insert>
	
	<update id="updateUnitSystStts" parameterType="String">
	    MERGE INTO TB_UNIT_SYST_STTS L
        USING (SELECT 'WEB01'                             AS SYST_ID,
                      TO_CHAR(SYSDATE,'YYYYMMDDHH24MISS') AS UPDT_DT,
                      #{sStatus}                          AS SYST_STTS_CD
                 FROM DUAL) M
        ON ( L.SYST_ID = M.SYST_ID )
        WHEN MATCHED THEN
          UPDATE SET L.UPDT_DT      = M.UPDT_DT,
                     L.SYST_STTS_CD = M.SYST_STTS_CD
        WHEN NOT MATCHED THEN
          INSERT (
	              L.SYST_ID,
	              L.UPDT_DT,
	              L.SYST_STTS_CD
                 )
          VALUES (
	              M.SYST_ID,
	              M.UPDT_DT,
	              M.SYST_STTS_CD
                 )
	</update>

</mapper>
