<?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="Member">
	
	<!-- 과거외사경찰 -->
	<resultMap id="exmemberResult" type="exmemberVO">
		<result property="userid" column="USERID" />
		<result property="passwd" column="PASSWD" />
		<result property="idno" column="IDNO" />
		<result property="name" column="NAME" />
		<result property="chnname" column="CHNNAME" />
		<result property="family" column="FAMILY" />
		<result property="address" column="ADDRESS" />
		<result property="email" column="EMAIL" />
		<result property="hphone" column="HPHONE" />
		<result property="ophone" column="OPHONE" />
		<result property="cphone" column="CPHONE" />
		<result property="sdate" column="SDATE" />
		<result property="pdate" column="PDATE" />
		<result property="adate" column="ADATE" />
		<result property="place1" column="PLACE1" />
		<result property="place1Str" column="PLACE1STR" />
		<result property="place2" column="PLACE2" />
		<result property="place2Str" column="PLACE2STR" />
		<result property="place3" column="PLACE3" />
		<result property="place3Str" column="PLACE3STR" />
		<result property="position" column="POSITION" />
		<result property="positionStr" column="POSITIONSTR" />
		<result property="duties" column="DUTIES" />
		<result property="dutiesStr" column="DUTIESSTR" />
		<result property="jobtype" column="JOBTYPE" />
		<result property="jobtypeStr" column="JOBTYPESTR" />
		<result property="inout" column="INOUT" />
		<result property="usertype" column="USERTYPE" />
		<result property="scholarship" column="SCHOLARSHIP" />
		<result property="scholarshipStr" column="SCHOLARSHIPSTR" />
		<result property="excareer" column="EXCAREER" />
		<result property="excareer1" column="EXCAREER1" />
		<result property="excareer2" column="EXCAREER2" />
		<result property="comment_" column="COMMENT_" />
		<result property="usegrade" column="USEGRADE" />
		<result property="cdate" column="CDATE" />
		<result property="nowPlace" column="NOWPLACE" />
		<result property="nowPlaceStr" column="NOWPLACESTR" />
		<result property="nowPosition" column="NOWPOSITION" />
		<result property="nowPositionStr" column="NOWPOSITIONSTR" />
		<result property="charge" column="CHARGE" />
		<result property="excareer3" column="EXCAREER3" />
		<result property="userimg" column="USER_IMG" />
	</resultMap>

	<select id="Member.getMember" parameterType="memberVO" resultType="memberVO">
		SELECT 
			*
		FROM
		<choose>
			<when test='usertype == "f"'>
				TAGENT
			</when>
			<otherwise>
				TUSER
			</otherwise>
		</choose>
		WHERE
			USERID = #{userid}
	</select>
	
	<select id="getFaListAll" parameterType="memberSearchVO" resultType="memberVO">
    select (ROW_NUMBER() OVER()) AS RNUM,
        (aa.PLACE1STR || ' ' || aa.PLACE2STR) PLACE3STR,
        TOTALEXCAREER_Y || '년 ' || TOTALEXCAREER_M || '개월' TOTALCAREER,
        aa.*
    from (select pl1.codenm place1str,
                pl2.codenm PLACE2STR,
                pst.codenm POSITIONSTR,
                jt.codenm JOBTYPESTR,
                MOD((EXCAREER_M + EXCAREER1_M + EXCAREER2_M + EXCAREER3_M), 12) TOTALEXCAREER_M,
                (EXCAREER_Y + EXCAREER1_Y + EXCAREER2_Y + EXCAREER3_Y) + FLOOR(MOD((EXCAREER_M + EXCAREER1_M + EXCAREER2_M + EXCAREER3_M), 12) / 12) TOTALEXCAREER_Y,
                a.*
          from (select *,
                      split_part(EXCAREER, '-', 1)::int EXCAREER_Y,
                      split_part(EXCAREER, '-', 2)::int EXCAREER_M,
                      split_part(EXCAREER1, '-', 1)::int EXCAREER1_Y,
                      split_part(EXCAREER1, '-', 2)::int EXCAREER1_M,
                      split_part(EXCAREER2, '-', 1)::int EXCAREER2_Y,
                      split_part(EXCAREER2, '-', 2)::int EXCAREER2_M,
                      split_part(EXCAREER3, '-', 1)::int EXCAREER3_Y,
                      split_part(EXCAREER3, '-', 2)::int EXCAREER3_M
                from tagent
                <where>
                  <if test="name != null and name != ''">
                    AND	NAME LIKE '%' || #{name} || '%'
                  </if>
                  <if test="place1 != null and place1 != ''">
                    AND	PLACE1 = #{place1}
                  </if>
                </where>
                ORDER BY
                    <if test="orderkey != null and orderkey != ''">
                      <choose>
                        <when test="ordercode == 7">
                          TOTALEXCAREER_Y <choose><when test="ordertype == 1">DESC</when><otherwise>ASC</otherwise></choose>,
                          TOTALEXCAREER_M <choose><when test="ordertype == 1">DESC</when><otherwise>ASC</otherwise></choose>,
                        </when>
                        <otherwise>
                          ${orderkey} <choose><when test="ordertype == 1">DESC</when><otherwise>ASC</otherwise></choose>,
                        </otherwise>
                      </choose>
                    </if>
                    PLACE1, PLACE2, PLACE3, POSITION DESC, DUTIES, NAME
          ) a
                inner join tcode pl1 on pl1.code1 = 'C001' and a.place1 = pl1.code2
                inner join tcode pl2 on a.place1 = pl2.code1 and a.place2 = pl2.code2
                inner join tcode pst on pst.code1 = 'C002' and a.position  = pst.code2
                inner join tcode jt on jt.code1 = 'C003' and a.jobtype = jt.code2
    ) aa
	</select>
	
	<select id="Member.getMemberSearchResult" parameterType="memberSearchVO" resultType="memberVO">
	<![CDATA[
		SELECT
			A.*, P.CODENM AS PLACE1STR, POS.CODENM AS POSITIONSTR
		FROM
	]]>
	<choose>
		<when test='usertype == "f"'>
			TAGENT A,
		</when>
		<when test='usertype == "g"'>
			TUSER A,
		</when>
		<otherwise>
			TAGENT A,
		</otherwise>
	</choose>
	<![CDATA[ 
			TCODE P, TCODE POS 
		WHERE
			A.PLACE1 = P.CODE2 AND P.CODE1 = 'C001'
			AND A.POSITION = POS.CODE2 AND POS.CODE1 = 'C002'
	]]>
		<if test="name != null and name != '' and userid == null and userid == ''">
			AND	NAME LIKE '%' || #{name} || '%'
		</if>
		<if test="name != null and name != '' and userid != null and userid != ''">
			AND	(NAME LIKE '%' || #{name} || '%' OR UPPER(USERID) LIKE '%' || UPPER(#{userid}) || '%')
		</if>
		<if test="place1 != null and place1 != ''">
			AND	A.PLACE1 = #{place1}
		</if>
	</select>
	
	<select id="Member.getFaMemberList" parameterType="memberSearchVO" resultType="memberVO">
    select (ROW_NUMBER() OVER()) AS RNUM,
          (aa.PLACE1STR || ' ' || aa.PLACE2STR) PLACE3STR,
          TOTALEXCAREER_Y || '년 ' || TOTALEXCAREER_M || '개월' TOTALCAREER,
          aa.*
    from (select pl1.codenm place1str,
                pl2.codenm PLACE2STR,
                pst.codenm POSITIONSTR,
                jt.codenm JOBTYPESTR,
                MOD((EXCAREER_M + EXCAREER1_M + EXCAREER2_M + EXCAREER3_M), 12) TOTALEXCAREER_M,
                (EXCAREER_Y + EXCAREER1_Y + EXCAREER2_Y + EXCAREER3_Y) + FLOOR(MOD((EXCAREER_M + EXCAREER1_M + EXCAREER2_M + EXCAREER3_M), 12) / 12) TOTALEXCAREER_Y,
                a.*
          from (select *,
                      split_part(EXCAREER, '-', 1)::int EXCAREER_Y,
                      split_part(EXCAREER, '-', 2)::int EXCAREER_M,
                      split_part(EXCAREER1, '-', 1)::int EXCAREER1_Y,
                      split_part(EXCAREER1, '-', 2)::int EXCAREER1_M,
                      split_part(EXCAREER2, '-', 1)::int EXCAREER2_Y,
                      split_part(EXCAREER2, '-', 2)::int EXCAREER2_M,
                      split_part(EXCAREER3, '-', 1)::int EXCAREER3_Y,
                      split_part(EXCAREER3, '-', 2)::int EXCAREER3_M
                from tagent
                <where>
                  <if test="name != null and name != ''">
                    AND	NAME LIKE '%' || #{name} || '%'
                  </if>
                  <if test="place1 != null and place1 != ''">
                    AND	PLACE1 = #{place1}
                  </if>
                </where>
                ORDER BY
                  <if test="orderkey != null and orderkey != ''">
                    <choose>
                      <when test="ordercode == 7">
                        TOTALEXCAREER_Y <choose><when test="ordertype == 1">DESC</when><otherwise>ASC</otherwise></choose>,
                        TOTALEXCAREER_M <choose><when test="ordertype == 1">DESC</when><otherwise>ASC</otherwise></choose>,
                      </when>
                      <otherwise>
                        ${orderkey} <choose><when test="ordertype == 1">DESC</when><otherwise>ASC</otherwise></choose>,
                      </otherwise>
                    </choose>
                  </if>
                  PLACE1, PLACE2, PLACE3, POSITION DESC, DUTIES, NAME
                limit #{recordCountPerPage} offset #{firstIndex}) a
                    inner join tcode pl1 on pl1.code1 = 'C001' and a.place1 = pl1.code2
                    inner join tcode pl2 on a.place1 = pl2.code1 and a.place2 = pl2.code2
                    inner join tcode pst on pst.code1 = 'C002' and a.position  = pst.code2
                    inner join tcode jt on jt.code1 = 'C003' and a.jobtype = jt.code2
          ) aa
	</select>
	
	<select id="Member.getCmmnListAll" parameterType="memberSearchVO" resultType="memberVO">
    select (ROW_NUMBER() OVER()) AS RNUM,
          aa.*
    from (select pl1.codenm place1str,
                b.recentdate,
                pl2.codenm PLACE2STR,
                pl3.codenm PLACE3STR,
                pst.codenm POSITIONSTR,
                jt.codenm JOBTYPESTR,
                a.*
          from tagent a
              inner join tcode pl1 on pl1.code1 = 'C001' and a.place1 = pl1.code2
              inner join tcode pl2 on a.place1 = pl2.code1 and a.place2 = pl2.code2
              inner join tcode pl3 on pl3.code1 = 'C009' and a.place3 = pl3.code2
              inner join tcode pst on pst.code1 = 'C002' and a.position  = pst.code2
              inner join tcode jt on jt.code1 = 'C003' and a.jobtype = jt.code2
              left outer join (SELECT IO_USERID, TO_CHAR(MAX(IO_REGDATE), 'YYYY-MM-DD HH24:MI:SS') AS RECENTDATE
                              FROM H3_LOGINOUT_LOG
                              <where>
                                <if test="place1 != null and place1 != ''">
                                  AND	IO_PLACE1 = #{place1}
                                </if>
                                <if test="name != null and name != ''">
                                  AND	IO_NAME LIKE '%' || #{name} || '%'
                                </if>
                              </where>
                              GROUP BY IO_USERID ) B ON A.USERID = B.IO_USERID
          <where>
            <if test="place1 != null and place1 != ''">
              AND	PLACE1 = #{place1}
            </if>
            <if test="name != null and name != ''">
              AND	NAME LIKE '%' || #{name} || '%'
            </if>
          </where>
          ORDER BY
            <if test="orderkey != null and orderkey != ''">
              ${orderkey} <choose><when test="ordertype == 1">DESC</when></choose>,
            </if>
            PLACE1, PLACE2, POSITION DESC, NAME ) aa
	</select>
	
	<select id="Member.getCmmnMemberList" parameterType="memberSearchVO" resultType="memberVO">
    select (ROW_NUMBER() OVER()) AS RNUM,
          aa.*
    from (select pl1.codenm place1str,
              b.recentdate,
              pl2.codenm PLACE2STR,
              pl3.codenm PLACE3STR,
              pst.codenm POSITIONSTR,
              jt.codenm JOBTYPESTR,
              a.*
          from tagent a
              inner join tcode pl1 on pl1.code1 = 'C001' and a.place1 = pl1.code2
              inner join tcode pl2 on a.place1 = pl2.code1 and a.place2 = pl2.code2
              inner join tcode pl3 on pl3.code1 = 'C009' and a.place3 = pl3.code2
              inner join tcode pst on pst.code1 = 'C002' and a.position  = pst.code2
              inner join tcode jt on jt.code1 = 'C003' and a.jobtype = jt.code2
              left outer join (SELECT IO_USERID, TO_CHAR(MAX(IO_REGDATE), 'YYYY-MM-DD HH24:MI:SS') AS RECENTDATE
                              FROM H3_LOGINOUT_LOG
                              <where>
                                <if test="place1 != null and place1 != ''">
                                  AND	IO_PLACE1 = #{place1}
                                </if>
                                <if test="name != null and name != ''">
                                  AND	IO_NAME LIKE '%' || #{name} || '%'
                                </if>
                              </where>
                              GROUP BY IO_USERID ) B ON A.USERID = B.IO_USERID
          <where>
            <if test="place1 != null and place1 != ''">
              AND	PLACE1 = #{place1}
            </if>
            <if test="name != null and name != ''">
              AND	NAME LIKE '%' || #{name} || '%'
            </if>
          </where>
          ORDER BY
              <if test="orderkey != null and orderkey != ''">
                ${orderkey} <choose><when test="ordertype == 1">DESC</when><otherwise>ASC</otherwise></choose>,
              </if>
              PLACE1, PLACE2, POSITION DESC, NAME
          limit #{recordCountPerPage} offset #{firstIndex} ) aa
	</select>
	
	
	<select id="Member.selectTotalCnt" parameterType="memberSearchVO" resultType="int">
	<![CDATA[	
		SELECT
			COUNT(*)
		FROM ]]>
	  	<choose>
			<when test='usertype == "f"'>
				TAGENT A
			</when>
			<otherwise>
				TUSER A
			</otherwise>
		</choose>
	</select>
	
	<select id="Member.selectListCnt" parameterType="memberSearchVO" resultType="int">
	<![CDATA[	
		SELECT 
			COUNT(*)
		FROM ]]>
	  	<choose>
			<when test='usertype == "f"'>
				TAGENT A
			</when>
			<otherwise>
				TUSER A
			</otherwise>
		</choose> <![CDATA[	
		WHERE
			1 = 1
		]]>
	    	<if test="name != null and name != ''">
				AND	NAME LIKE '%' || #{name} || '%'
			</if>
	        <if test="place1 != null and place1 != ''">
				AND	PLACE1 = #{place1}
			</if>
	</select>
	
	<insert id="Member.insertFaMember" parameterType="memberVO">
	<![CDATA[	
		INSERT INTO
			TAGENT (
				USERID, PASSWD, IDNO, NAME,
				CHNNAME, FAMILY, ADDRESS, EMAIL,
				HPHONE, OPHONE, CPHONE,
				SDATE, PDATE, ADATE,
				PLACE1, PLACE2, PLACE3,
				POSITION, DUTIES, JOBTYPE, INOUT, USERTYPE, SCHOLARSHIP,
				EXCAREER, EXCAREER1, EXCAREER2, EXCAREER3,
				COMMENT_,
				CHARGE, EXPLACE, USEGRADE, USERIMG, USERSIGN
		) VALUES (
			#{userid}, 
	]]>
		<choose>
		<when test="isHashedPasswd eq true">
		<![CDATA[
			#{passwd},
		]]>
		</when>
		<otherwise>
		<![CDATA[
			XX1.ENC_VARCHAR2_INS(#{passwd}, 10, 'SHA256'),
		]]>
		</otherwise>
		</choose>			
	<![CDATA[	 
			#{idno, jdbcType=CHAR}, #{name},
			#{chnname}, #{family}, #{address}, #{email},
			#{hphone}, #{ophone}, #{cphone},
			#{sdate}, #{pdate}, #{adate},
			#{place1}, #{place2}, #{place3},
			#{position}, #{duties}, #{jobtype}, #{inout}, 'f', #{scholarship},
			#{excareer}, #{excareer1}, #{excareer2}, #{excareer3},
			#{comment_},
			#{charge}, #{explace}, #{usegrade}, #{userimg,jdbcType=VARCHAR}, #{usersign,jdbcType=VARCHAR}
		)
	]]>
	</insert>

	<update id="Member.updateFaMember" parameterType="memberVO">
	<![CDATA[
		UPDATE
			TAGENT
		SET
	]]>
		<!-- 비밀번호 값이 null이 아니면 수정 가능(임영민, 2019-09-30) -->
 		<if test="passwd != null and passwd != ''"><![CDATA[
			PASSWD = XX1.ENC_VARCHAR2_INS(#{passwd}, 10, 'SHA256'), 
		]]></if>
	<![CDATA[					
			NAME = #{name}, CHNNAME = #{chnname}, FAMILY = #{family}, ADDRESS = #{address}, EMAIL = #{email},
			HPHONE = #{hphone}, OPHONE = #{ophone}, CPHONE = #{cphone},
			SDATE = #{sdate}, PDATE = #{pdate}, ADATE = #{adate},
			PLACE1 = #{place1}, PLACE2 = #{place2}, PLACE3 = #{place3},
			POSITION = #{position}, DUTIES = #{duties}, JOBTYPE = #{jobtype}, INOUT = #{inout}, SCHOLARSHIP = #{scholarship},
			EXCAREER = #{excareer}, EXCAREER1 = #{excareer1}, EXCAREER2 = #{excareer2}, EXCAREER3 = #{excareer3},
			COMMENT_ = #{comment_}, LOGINDATE = TO_CHAR(NOW(), 'YYYY-MM-DD'),
			CHARGE = #{charge}, EXPLACE = #{explace}, USEGRADE = #{usegrade}, USERIMG = #{userimg,jdbcType=VARCHAR}, USERSIGN = #{usersign,jdbcType=VARCHAR},
			CHKCNT = COALESCE(#{chkcnt}, 0)
		WHERE
			USERID = #{userid}
	]]>
	</update>

	<insert id="insertCmmnMember" parameterType="memberVO">
	<![CDATA[
		INSERT INTO TUSER
			( USERID, NAME, PASSWD, PLACE1, PLACE2, POSITION, CDATE, LDATE, WRITER )
		VALUES
			( #{userid}, #{name}, 
	]]>
		<choose>
		<when test="isHashedPasswd eq true">
		<![CDATA[
			#{passwd},
		]]>
		</when>
		<otherwise>
		<![CDATA[
			XX1.ENC_VARCHAR2_INS(#{passwd}, 10, 'SHA256'),
		]]>
		</otherwise>
		</choose>			
	<![CDATA[
			  #{place1}, #{place2}, #{position}, TO_CHAR(NOW(), 'YYYYMMDD'), TO_CHAR(NOW(), 'YYYYMMDD'), #{writer} )
	]]>
	</insert>	

	<update id="Member.updateCmmnMemberInfo" parameterType="memberVO">
	<![CDATA[
		UPDATE
			TUSER
		SET
	]]>
		<if test="passwd != null and passwd != ''"><![CDATA[
			PASSWD = XX1.ENC_VARCHAR2_INS(#{passwd}, 10, 'SHA256'), 
		]]></if>
	<![CDATA[					
			NAME = #{name}, 
			PLACE1 = #{place1}, 
			PLACE2 = #{place2}, 
			POSITION = #{position},
			CHKCNT = COALESCE(#{chkcnt}, 0)
		WHERE
			USERID = #{userid}
	]]>
	</update>
	
	<delete id="deleteFaMember" parameterType="memberVO">
	<![CDATA[
		DELETE FROM TAGENT WHERE USERID = #{userid}
	]]>
	</delete>
	
	<update id="updateCmmnMember" parameterType="memberVO">
	<![CDATA[
		UPDATE
			TUSER
		SET
			CHKCNT = #{chkcnt}
		WHERE
			USERID = #{userid}
	]]>
	</update>
	
	<delete id="deleteCmmnMember" parameterType="memberVO">
	<![CDATA[
		DELETE FROM TUSER WHERE USERID = #{userid}
	]]>
	</delete>
	
	<update id="Member.updatePassword" parameterType="memberVO">
		UPDATE 
	  	<choose>
			<when test='usertype == "f"'>
				TAGENT A
			</when>
			<otherwise>
				TUSER A
			</otherwise>
		</choose>
    <![CDATA[
      SET
        LOGINDATE = TO_CHAR(NOW(), 'YYYY-MM-DD'),
        PASSWD = XX1.ENC_VARCHAR2_INS(#{passwd}, 10, 'SHA256')
      WHERE
        USERID = #{userid}
    ]]>
	</update>
	
	
	<select id="Member.getCapacityManagement" resultType="hashmap">
	<![CDATA[	
		SELECT CASE RESULT_LIST.PLACE
              WHEN 'PS0' THEN '계'
              WHEN 'PS001' THEN '소계'
              ELSE CODE.CODENM
           END AS CODENM,
           RESULT_LIST.*,
           CURRENT_CNT - TOT_CNT AS EXCESS
		FROM (
		  SELECT
		    A.PLACE1 AS PLACE,
        COALESCE(A.TOT_CNT, 0) AS TOT_CNT,	
		    COALESCE(B.CURRENT_CNT,0) AS CURRENT_CNT,	
		    COALESCE(A.POSITION204,0) AS POSITION204, COALESCE(B.CNT_204,0) AS CNT_204,	
		    COALESCE(A.POSITION203,0) AS POSITION203, COALESCE(B.CNT_203,0) AS CNT_203,	
		    COALESCE(A.POSITION202,0) AS POSITION202, COALESCE(B.CNT_202,0) AS CNT_202,	
		    COALESCE(A.POSITION201,0) AS POSITION201, COALESCE(B.CNT_201,0) AS CNT_201,
		    COALESCE(A.POSITION104,0) AS POSITION104, COALESCE(B.CNT_104,0) AS CNT_104,	
		    COALESCE(A.POSITION103,0) AS POSITION103, COALESCE(B.CNT_103,0) AS CNT_103,
		    COALESCE(A.POSITION102,0) AS POSITION102, COALESCE(B.CNT_102,0) AS CNT_102 
		  FROM (  
		    SELECT 
		      'PS0' AS PLACE1,	
		      SUM(COALESCE((POSITION204 + POSITION203 + POSITION202 + POSITION201 + POSITION104 + POSITION103 + POSITION102),0)) AS TOT_CNT,	
		      SUM(COALESCE(POSITION204,0)) AS POSITION204,	
		      SUM(COALESCE(POSITION203,0)) AS POSITION203,	
		      SUM(COALESCE(POSITION202,0)) AS POSITION202,	
		      SUM(COALESCE(POSITION201,0)) AS POSITION201,	
		      SUM(COALESCE(POSITION104,0)) AS POSITION104,	
		      SUM(COALESCE(POSITION103,0)) AS POSITION103,	
		      SUM(COALESCE(POSITION102,0)) AS POSITION102 
		    FROM TAGENTNUM
        WHERE PLACE1 <> 'PS95'
		  ) A INNER JOIN (
		    SELECT 
		      'PS0' AS PLACE1, 
		      COUNT(*) AS CURRENT_CNT, 
		      SUM(CASE POSITION WHEN '204' THEN 1 ELSE 0 END) AS CNT_204, 
		      SUM(CASE POSITION WHEN '203' THEN 1 ELSE 0 END) AS CNT_203, 
		      SUM(CASE POSITION WHEN '202' THEN 1 ELSE 0 END) AS CNT_202, 
		      SUM(CASE POSITION WHEN '201' THEN 1 ELSE 0 END) AS CNT_201, 
		      SUM(CASE POSITION WHEN '104' THEN 1 ELSE 0 END) AS CNT_104, 
		      SUM(CASE POSITION WHEN '103' THEN 1 ELSE 0 END) AS CNT_103, 
		      SUM(CASE POSITION WHEN '102' THEN 1 ELSE 0 END) AS CNT_102
		    FROM 
		      TAGENT,
		      T_SSO_AUTH_CODE
		    WHERE 
		      PLACE1 <> 'PS95' AND 
		      PLACE3 NOT IN ('09', '19') AND
		      CODE_ID = USEGRADE AND ROLE_LEVEL > 1
		  ) B
		  ON 
		    A.PLACE1 = B.PLACE1 
		  
		  UNION 
		  
		  SELECT 
		    A.PLACE1 AS PLACE, 
		    COALESCE((A.POSITION204 + A.POSITION203 + A.POSITION202 + A.POSITION201 + A.POSITION104 + A.POSITION103 + A.POSITION102), 0) AS TOT_CNT, 
		    COALESCE(B.CURRENT_CNT,0) AS CURRENT_CNT, 
		    COALESCE(A.POSITION204,0) AS POSITION204, COALESCE(B.CNT_204,0) AS CNT_204, 
		    COALESCE(A.POSITION203,0) AS POSITION203, COALESCE(B.CNT_203,0) AS CNT_203, 
		    COALESCE(A.POSITION202,0) AS POSITION202, COALESCE(B.CNT_202,0) AS CNT_202, 
		    COALESCE(A.POSITION201,0) AS POSITION201, COALESCE(B.CNT_201,0) AS CNT_201, 
		    COALESCE(A.POSITION104,0) AS POSITION104, COALESCE(B.CNT_104,0) AS CNT_104, 
		    COALESCE(A.POSITION103,0) AS POSITION103, COALESCE(B.CNT_103,0) AS CNT_103, 
		    COALESCE(A.POSITION102,0) AS POSITION102, COALESCE(B.CNT_102,0) AS CNT_102 
		  FROM TAGENTNUM A 
		    INNER JOIN (
		      SELECT 
		        PLACE1, 
		        COUNT(*) AS CURRENT_CNT, 
		        SUM(CASE POSITION WHEN '204' THEN 1 ELSE 0 END) AS CNT_204, 
		        SUM(CASE POSITION WHEN '203' THEN 1 ELSE 0 END) AS CNT_203, 
		        SUM(CASE POSITION WHEN '202' THEN 1 ELSE 0 END) AS CNT_202, 
		        SUM(CASE POSITION WHEN '201' THEN 1 ELSE 0 END) AS CNT_201, 
		        SUM(CASE POSITION WHEN '104' THEN 1 ELSE 0 END) AS CNT_104, 
		        SUM(CASE POSITION WHEN '103' THEN 1 ELSE 0 END) AS CNT_103, 
		        SUM(CASE POSITION WHEN '102' THEN 1 ELSE 0 END) AS CNT_102
		      FROM 
		        TAGENT,
		        T_SSO_AUTH_CODE
		      WHERE 
		        PLACE1 = 'PS00' AND 
		        PLACE3 NOT IN ('09', '19') AND
		        CODE_ID = USEGRADE AND ROLE_LEVEL > 1
		      GROUP BY 
		        PLACE1 ) B
		    ON 
		      A.PLACE1 = B.PLACE1 
		  WHERE 
		    A.PLACE1 = 'PS00'
		  
		  UNION 
		  
		  SELECT 
		    A.PLACE1 AS PLACE,	
		    COALESCE(A.TOT_CNT, 0) AS TOT_CNT,	
		    COALESCE(B.CURRENT_CNT,0) AS CURRENT_CNT,	
		    COALESCE(A.POSITION204,0) AS POSITION204, COALESCE(B.CNT_204,0) AS CNT_204,	
		    COALESCE(A.POSITION203,0) AS POSITION203, COALESCE(B.CNT_203,0) AS CNT_203,	
		    COALESCE(A.POSITION202,0) AS POSITION202, COALESCE(B.CNT_202,0) AS CNT_202,	
		    COALESCE(A.POSITION201,0) AS POSITION201, COALESCE(B.CNT_201,0) AS CNT_201,
		    COALESCE(A.POSITION104,0) AS POSITION104, COALESCE(B.CNT_104,0) AS CNT_104,	
		    COALESCE(A.POSITION103,0) AS POSITION103, COALESCE(B.CNT_103,0) AS CNT_103,
		    COALESCE(A.POSITION102,0) AS POSITION102, COALESCE(B.CNT_102,0) AS CNT_102 
		  FROM (  
		    SELECT 
		      'PS001' AS PLACE1,
		      SUM(COALESCE((POSITION204 + POSITION203 + POSITION202 + POSITION201 + POSITION104 + POSITION103 + POSITION102),0)) AS TOT_CNT,	
		      SUM(COALESCE(POSITION204,0)) AS POSITION204,	
		      SUM(COALESCE(POSITION203,0)) AS POSITION203,	
		      SUM(COALESCE(POSITION202,0)) AS POSITION202,	
		      SUM(COALESCE(POSITION201,0)) AS POSITION201,	
		      SUM(COALESCE(POSITION104,0)) AS POSITION104,	
		      SUM(COALESCE(POSITION103,0)) AS POSITION103,	
		      SUM(COALESCE(POSITION102,0)) AS POSITION102 
		    FROM 
		      TAGENTNUM
		    WHERE 
		      PLACE1 <> 'PS00' AND 
		      PLACE1 <> 'PS95'
		    ) A INNER JOIN (
		    SELECT 
		      'PS001' AS PLACE1,
		      COUNT(*) AS CURRENT_CNT,
		      SUM(CASE POSITION WHEN '204' THEN 1 ELSE 0 END) AS CNT_204, 
		      SUM(CASE POSITION WHEN '203' THEN 1 ELSE 0 END) AS CNT_203, 
		      SUM(CASE POSITION WHEN '202' THEN 1 ELSE 0 END) AS CNT_202, 
		      SUM(CASE POSITION WHEN '201' THEN 1 ELSE 0 END) AS CNT_201, 
		      SUM(CASE POSITION WHEN '104' THEN 1 ELSE 0 END) AS CNT_104, 
		      SUM(CASE POSITION WHEN '103' THEN 1 ELSE 0 END) AS CNT_103, 
		      SUM(CASE POSITION WHEN '102' THEN 1 ELSE 0 END) AS CNT_102
		    FROM 
		      TAGENT 
		    WHERE 
		      PLACE1 <> 'PS00' AND 
		      PLACE1 <> 'PS95' AND 
		      PLACE3 NOT IN ('09', '19')
		    ) B
		    ON 
		      A.PLACE1 = B.PLACE1 
		    WHERE 
		      A.PLACE1 <> 'PS00' AND 
		      A.PLACE1 <> 'PS95'
		      
		  UNION 
		  
		    SELECT 
		      A.PLACE1 AS PLACE, 
		      COALESCE((A.POSITION204 + A.POSITION203 + A.POSITION202 + A.POSITION201 + A.POSITION104 + A.POSITION103 + A.POSITION102), 0) AS TOT_CNT, 
		      COALESCE(B.CURRENT_CNT,0) AS CURRENT_CNT, 
		      COALESCE(A.POSITION204,0) AS POSITION204, COALESCE(B.CNT_204,0) AS CNT_204, 
		      COALESCE(A.POSITION203,0) AS POSITION203, COALESCE(B.CNT_203,0) AS CNT_203, 
		      COALESCE(A.POSITION202,0) AS POSITION202, COALESCE(B.CNT_202,0) AS CNT_202, 
		      COALESCE(A.POSITION201,0) AS POSITION201, COALESCE(B.CNT_201,0) AS CNT_201, 
		      COALESCE(A.POSITION104,0) AS POSITION104, COALESCE(B.CNT_104,0) AS CNT_104, 
		      COALESCE(A.POSITION103,0) AS POSITION103, COALESCE(B.CNT_103,0) AS CNT_103, 
		      COALESCE(A.POSITION102,0) AS POSITION102, COALESCE(B.CNT_102,0) AS CNT_102 
		     FROM 
		      TAGENTNUM A LEFT OUTER JOIN (
		        SELECT 
		          PLACE1, 
		          COUNT(*) AS CURRENT_CNT, 
		          SUM(CASE POSITION WHEN '204' THEN 1 ELSE 0 END) AS CNT_204, 
		          SUM(CASE POSITION WHEN '203' THEN 1 ELSE 0 END) AS CNT_203, 
		          SUM(CASE POSITION WHEN '202' THEN 1 ELSE 0 END) AS CNT_202, 
		          SUM(CASE POSITION WHEN '201' THEN 1 ELSE 0 END) AS CNT_201, 
		          SUM(CASE POSITION WHEN '104' THEN 1 ELSE 0 END) AS CNT_104, 
		          SUM(CASE POSITION WHEN '103' THEN 1 ELSE 0 END) AS CNT_103, 
		          SUM(CASE POSITION WHEN '102' THEN 1 ELSE 0 END) AS CNT_102
		        FROM 
		          TAGENT 
		        WHERE
		          PLACE1 <> 'PS00' AND 
		          PLACE1 <> 'PS95' AND 
		          PLACE3 NOT IN ('09', '19') 
		        GROUP BY 
		          PLACE1) B
		      ON 
		        A.PLACE1 = B.PLACE1 
		    WHERE 
		      A.PLACE1 <> 'PS00' AND 
		      A.PLACE1 <> 'PS95'
		    ORDER BY 
		      PLACE
		) RESULT_LIST 
		LEFT JOIN
		  TCODE CODE
		ON
		  RESULT_LIST.PLACE = CODE.CODE2 AND
		  (CODE.CODE1 = 'C000' OR CODE2 NOT IN (PLACE))
	]]>
	</select>
	<select id="Member.getCareerStatus" resultType="hashmap">
	<![CDATA[	
		SELECT
		  CASE RESULT_LIST.PLACE1 WHEN 'PS' THEN '계' WHEN 'PS001' THEN '소계'  ELSE CODE.CODENM END AS CODENM,
		  FLOOR(TOT_CNT_M/12) + TOT_CNT_Y + FLOOR(ADD_CAREER/12) || '년 ' || MOD(TOT_CNT_M + ADD_CAREER, 12) || '개월' AS TOT_CAREER,
		  FLOOR(CAREER_M/12) + CAREER_Y + FLOOR(ADD_CAREER/12) || '년 ' || MOD(CAREER_M + ADD_CAREER, 12) || '개월' AS CAREER,
		  FLOOR(CAREER1_M/12) + CAREER1_Y || '년 ' || MOD(CAREER1_M, 12) || '개월' AS CAREER1,
		  FLOOR(CAREER2_M/12) + CAREER2_Y || '년 ' || MOD(CAREER2_M, 12) || '개월' AS CAREER2,
		  FLOOR(CAREER3_M/12) + CAREER3_Y || '년 ' || MOD(CAREER3_M, 12) || '개월' AS CAREER3
		FROM (
		    SELECT 'PS' AS PLACE1 
		      ,SUM(CAREER_Y+CAREER1_Y+CAREER2_Y+CAREER3_Y) AS TOT_CNT_Y
		      ,SUM(CAREER_M+CAREER1_M+CAREER2_M+CAREER3_M) AS TOT_CNT_M
		      ,SUM(COALESCE(CAREER_Y, 0)) AS CAREER_Y
		      ,SUM(COALESCE(CAREER_M, 0)) AS CAREER_M
		      ,SUM(COALESCE(CAREER1_Y, 0)) AS CAREER1_Y
		      ,SUM(COALESCE(CAREER1_M, 0)) AS CAREER1_M
		      ,SUM(COALESCE(CAREER2_Y, 0)) AS CAREER2_Y
		      ,SUM(COALESCE(CAREER2_M, 0)) AS CAREER2_M
		      ,SUM(COALESCE(CAREER3_Y, 0)) AS CAREER3_Y
		      ,SUM(COALESCE(CAREER3_M, 0)) AS CAREER3_M
		      ,SUM((TO_NUMBER(TO_CHAR(NOW(), 'MM'), '99') + (TO_NUMBER(TO_CHAR(NOW(), 'YYYY'), '9999')
		            - TO_NUMBER(TO_CHAR(TO_DATE(ADATE, 'YYYY-MM-DD'), 'YYYY'), '9999'))*12) 
		            - TO_NUMBER(TO_CHAR(TO_DATE(ADATE, 'YYYY-MM-DD'), 'MM'), '99')) AS ADD_CAREER
		    FROM H3_CAREER_STAT 
		  UNION 
		  SELECT 'PS00' AS PLACE1 
		    ,SUM(CAREER_Y+CAREER1_Y+CAREER2_Y+CAREER3_Y) AS TOT_CNT_Y
		    ,SUM(CAREER_M+CAREER1_M+CAREER2_M+CAREER3_M) AS TOT_CNT_M
		    ,SUM(COALESCE(CAREER_Y, 0)) AS CAREER_Y
		    ,SUM(COALESCE(CAREER_M, 0)) AS CAREER_M
		    ,SUM(COALESCE(CAREER1_Y, 0)) AS CAREER1_Y
		    ,SUM(COALESCE(CAREER1_M, 0)) AS CAREER1_M
		    ,SUM(COALESCE(CAREER2_Y, 0)) AS CAREER2_Y
		    ,SUM(COALESCE(CAREER2_M, 0)) AS CAREER2_M
		    ,SUM(COALESCE(CAREER3_Y, 0)) AS CAREER3_Y
		    ,SUM(COALESCE(CAREER3_M, 0)) AS CAREER3_M
		    ,SUM((TO_NUMBER(TO_CHAR(NOW(), 'MM'), '99') + (TO_NUMBER(TO_CHAR(NOW(), 'YYYY'), '9999')
		      - TO_NUMBER(TO_CHAR(TO_DATE(ADATE, 'YYYY-MM-DD'), 'YYYY'), '9999'))*12) 
		      - TO_NUMBER(TO_CHAR(TO_DATE(ADATE, 'YYYY-MM-DD'), 'MM'), '99')) AS ADD_CAREER
		  FROM 
		    H3_CAREER_STAT 
		  WHERE 
		    PLACE1 = 'PS00' 
		  
		  UNION 
		  
		  SELECT 
		    'PS001' AS PLACE1 
		    ,SUM(CAREER_Y+CAREER1_Y+CAREER2_Y+CAREER3_Y) AS TOT_CNT_Y
		    ,SUM(CAREER_M+CAREER1_M+CAREER2_M+CAREER3_M) AS TOT_CNT_M
		    ,SUM(COALESCE(CAREER_Y, 0)) AS CAREER_Y
		    ,SUM(COALESCE(CAREER_M, 0)) AS CAREER_M
		    ,SUM(COALESCE(CAREER1_Y, 0)) AS CAREER1_Y
		    ,SUM(COALESCE(CAREER1_M, 0)) AS CAREER1_M
		    ,SUM(COALESCE(CAREER2_Y, 0)) AS CAREER2_Y
		    ,SUM(COALESCE(CAREER2_M, 0)) AS CAREER2_M
		    ,SUM(COALESCE(CAREER3_Y, 0)) AS CAREER3_Y
		    ,SUM(COALESCE(CAREER3_M, 0)) AS CAREER3_M
		    ,SUM((TO_NUMBER(TO_CHAR(NOW(), 'MM'), '99') + (TO_NUMBER(TO_CHAR(NOW(), 'YYYY'), '9999')
		    - TO_NUMBER(TO_CHAR(TO_DATE(ADATE, 'YYYY-MM-DD'), 'YYYY'), '9999'))*12) 
		    - TO_NUMBER(TO_CHAR(TO_DATE(ADATE, 'YYYY-MM-DD'), 'MM'), '99')) AS ADD_CAREER
		  FROM 
		    H3_CAREER_STAT 
		  WHERE 
		    PLACE1 <> 'PS00' 
		  
		  UNION 
		  SELECT 
		    PLACE1 
		    ,SUM(CAREER_Y+CAREER1_Y+CAREER2_Y+CAREER3_Y) AS TOT_CNT_Y
		    ,SUM(CAREER_M+CAREER1_M+CAREER2_M+CAREER3_M) AS TOT_CNT_M
		    ,SUM(COALESCE(CAREER_Y, 0)) AS CAREER_Y
		    ,SUM(COALESCE(CAREER_M, 0)) AS CAREER_M
		    ,SUM(COALESCE(CAREER1_Y, 0)) AS CAREER1_Y
		    ,SUM(COALESCE(CAREER1_M, 0)) AS CAREER1_M
		    ,SUM(COALESCE(CAREER2_Y, 0)) AS CAREER2_Y
		    ,SUM(COALESCE(CAREER2_M, 0)) AS CAREER2_M
		    ,SUM(COALESCE(CAREER3_Y, 0)) AS CAREER3_Y
		    ,SUM(COALESCE(CAREER3_M, 0)) AS CAREER3_M
		    ,SUM((TO_NUMBER(TO_CHAR(NOW(), 'MM'), '99') + (TO_NUMBER(TO_CHAR(NOW(), 'YYYY'), '9999')
		    - TO_NUMBER(TO_CHAR(TO_DATE(ADATE, 'YYYY-MM-DD'), 'YYYY'), '9999'))*12) 
		    - TO_NUMBER(TO_CHAR(TO_DATE(ADATE, 'YYYY-MM-DD'), 'MM'), '99')) AS ADD_CAREER
		  FROM 
		    H3_CAREER_STAT 
		  WHERE 
		    PLACE1 <> 'PS00'
		  GROUP BY 
		    PLACE1
		) RESULT_LIST LEFT JOIN
		  TCODE CODE
		ON
		  RESULT_LIST.PLACE1 = CODE.CODE2 AND
		  (CODE.CODE1 = 'C000' OR CODE2 NOT IN (PLACE1))
		ORDER BY UPPER(PLACE1)
	]]>
	</select>
	
	<select id="selectExmemeber" parameterType="exmemberVO" resultMap="exmemberResult">
	<![CDATA[
		SELECT 
			* 
		FROM ( 
			SELECT
				(SELECT CODENM FROM TCODE WHERE CODE1 = 'C001' AND CODE2 = EXA.PLACE1) AS PLACE1STR,
				(SELECT CODENM FROM TCODE WHERE CODE1 = EXA.PLACE1 AND CODE2 = EXA.PLACE2) AS PLACE2STR,
				(SELECT CODENM FROM TCODE WHERE CODE1 = 'C009' AND CODE2 = EXA.PLACE3) AS PLACE3STR,
				(SELECT CODENM FROM TCODE WHERE CODE1 = 'C002' AND CODE2 = EXA.POSITION) AS POSITIONSTR,
				(SELECT CODENM FROM TCODE WHERE CODE1 = 'C003' AND CODE2 = EXA.JOBTYPE) AS JOBTYPESTR,
				(SELECT CODENM FROM TCODE WHERE CODE1 = 'C004' AND CODE2 = EXA.DUTIES) AS DUTIESSTR,
				(SELECT CODENM FROM TCODE WHERE CODE1 = 'C005' AND CODE2 = EXA.SCHOLARSHIP) AS SCHOLARSHIPSTR,
				(SELECT CODENM FROM TCODE WHERE CODE1 = 'C001' AND CODE2 = EXA.NOWPLACE) AS NOWPLACESTR,
				(SELECT CODENM FROM TCODE WHERE CODE1 = 'C002' AND CODE2 = EXA.NOWPOSITION) AS NOWPOSITIONSTR,
				EXA.*
			FROM
			  	TEXAGENT EXA
			WHERE
			  	EXA.USERID = #{userid}
		  	ORDER BY CDATE DESC
	  	) WHERE ROWNUM = 1
	]]>
	</select>
	
	<select id="Member.exmemberList" parameterType="memberSearchVO" resultType="memberVO">
    SELECT
        (ROW_NUMBER() OVER()) RNUM,
        MEMBER_LIST.*
    FROM (SELECT MEMBER_LIST.*
          FROM (SELECT
                  (SELECT CODENM FROM TCODE WHERE CODE1 = 'C001' AND CODE2 = EA.PLACE1) AS PLACE1STR,
                  (SELECT CODENM FROM TCODE WHERE CODE1 = 'C002' AND CODE2 = EA.POSITION) AS POSITIONSTR,
                  (SELECT CODENM FROM TCODE WHERE CODE1 = EA.PLACE1 AND CODE2 = EA.PLACE2) AS PLACE2STR,
                  (SELECT CODENM FROM TCODE WHERE CODE1 = 'C001' AND CODE2 = EA.NOWPLACE) AS NOWPLACESTR,
                  (SELECT CODENM FROM TCODE WHERE CODE1 = 'C002' AND CODE2 = EA.NOWPOSITION) AS NOWPOSITIONSTR,
                  EA.*
                FROM TEXAGENT EA
                <where>
                  <if test="place1 != null and place1 != ''">
                    AND	PLACE1 = #{place1}
                  </if>
                  <if test="position != null and position != ''">
                    AND	Position = #{position}
                  </if>
                  <if test="name != null and name != ''">
                    AND	NAME LIKE '%' || #{name} || '%'
                  </if>
                </where>
                ORDER by
                      <if test="orderkey != null and orderkey != ''">
                        ${orderkey} <choose><when test="ordertype == 1">DESC</when><otherwise>ASC</otherwise></choose>,
                      </if>
                      PLACE1, POSITION, USERID
                limit #{recordCountPerPage} offset #{firstIndex}
                ) MEMBER_LIST
          ) MEMBER_LIST
	</select>
	
	<select id="Member.selectExmemberTotalCnt" parameterType="memberSearchVO" resultType="int">
	<![CDATA[	
		SELECT
			COUNT(*)
		FROM 
			TEXAGENT
	]]>
	</select>
	
	<select id="Member.selectExmemberListCnt" parameterType="memberSearchVO" resultType="int">
	<![CDATA[	
		SELECT 
			COUNT(*)
		FROM 
			TEXAGENT
		WHERE
			1 = 1
		]]>
	    	<if test="name != null and name != ''">
				AND	NAME LIKE '%' || #{name} || '%'
			</if>
	        <if test="place1 != null and place1 != ''">
				AND	PLACE1 = #{place1}
			</if>
			<if test="position != null and position != ''">
				AND	Position = #{position}
			</if>
	</select>
	
	<insert id="Member.insertCareerStat" parameterType="memberVO">
	<![CDATA[
		INSERT INTO H3_CAREER_STAT (
			USERID, PLACE1, CAREER_Y, CAREER_M,
			CAREER1_Y, CAREER1_M, CAREER2_Y, CAREER2_M, CAREER3_Y, CAREER3_M,
			REGDATE, ADATE
		)
		VALUES (
			#{userid}, #{place1}, #{excareer_y}, #{excareer_m},
			#{excareer1_y}, #{excareer1_m}, #{excareer2_y}, #{excareer2_m}, #{excareer3_y}, #{excareer3_m},
      NOW(), to_char(now(), 'YY/MM/DD')
		) 
	]]>
	</insert>
	
	<update id="Member.updateCareerStat" parameterType="memberVO">
	<![CDATA[
		UPDATE
			H3_CAREER_STAT
		SET
			CAREER_Y = #{excareer_y}, 
			CAREER_M = #{excareer_m},
			CAREER1_Y = #{excareer1_y}, 
			CAREER1_M = #{excareer1_m}, 
			CAREER2_Y = #{excareer2_y}, 
			CAREER2_M = #{excareer2_m}, 
			CAREER3_Y = #{excareer3_y}, 
			CAREER3_M = #{excareer3_m},
			ADATE = NOW()
		WHERE
			USERID = #{userid} 
	]]>
	</update>

	<update id="updateExMember" parameterType="exmemberVO">
	<![CDATA[
		UPDATE
			TEXAGENT
		SET
			NAME = #{name}, CHNNAME = #{chnname}, FAMILY = #{family}, ADDRESS = #{address}, EMAIL = #{email},
			HPHONE = #{hphone}, OPHONE = #{ophone}, CPHONE = #{cphone},
			SDATE = #{sdate}, PDATE = #{pdate}, ADATE = #{adate}, CDATE = #{cdateEx},
			PLACE1 = #{place1}, PLACE2 = #{place2}, PLACE3 = #{place3},
			POSITION = #{position}, DUTIES = #{duties}, JOBTYPE = #{jobtype}, INOUT = #{inout}, SCHOLARSHIP = #{scholarship},
			EXCAREER = #{excareer}, EXCAREER1 = #{excareer1}, EXCAREER2 = #{excareer2}, EXCAREER3 = #{excareer3},
			COMMENT_ = #{comment_}, CHARGE = #{charge}, USEGRADE = #{usegrade}, USER_IMG = #{userimg,jdbcType=VARCHAR},
			USERTYPE = #{usertype}, NOWPLACE = #{nowPlace}, NOWPOSITION = #{nowPosition}
		WHERE
			USERID = #{userid}
	]]>
	</update>

	<delete id="deleteExMember" parameterType="exmemberVO">
	<![CDATA[
		DELETE FROM TEXAGENT WHERE USERID = #{userid}
	]]>
	</delete>
	
	<insert id="insertExMember" parameterType="exmemberVO">
	<![CDATA[
		INSERT INTO TEXAGENT 
		(
			USERID, PASSWD, NAME, CHNNAME, FAMILY, ADDRESS, EMAIL, HPHONE, OPHONE, CPHONE,
			SDATE, PDATE, ADATE, PLACE1, PLACE2, PLACE3, POSITION, DUTIES, JOBTYPE, USERTYPE, 
			SCHOLARSHIP, EXCAREER, EXCAREER1, EXCAREER2, EXCAREER3, USEGRADE, INOUT, COMMENT_, USER_IMG, CDATE
		) 
		VALUES 
		(
			#{userid}, 
	]]>
		<choose>
		<when test="isHashedPasswd eq true">
		<![CDATA[
			#{passwd},
		]]>
		</when>
		<otherwise>
		<![CDATA[
			XX1.ENC_VARCHAR2_INS(#{passwd}, 10, 'SHA256'),
		]]>
		</otherwise>
		</choose>			
	<![CDATA[	 
			#{name}, #{chnname}, #{family}, #{address}, #{email}, #{hphone}, #{ophone}, #{cphone},
			#{sdate}, #{pdate}, #{adate}, #{place1}, #{place2}, #{place3}, #{position}, #{duties}, #{jobtype}, 'g',
			#{scholarship}, #{excareer}, #{excareer1}, #{excareer2}, #{excareer3}, #{inout}, #{comment_}, #{userimg,jdbcType=VARCHAR}, NOW()
		)
	]]>
	</insert>	

	<insert id="insertExMemberByMemberVO" parameterType="memberVO">
	<![CDATA[
		INSERT INTO TEXAGENT 
		(
			USERID, PASSWD, NAME, CHNNAME, FAMILY, ADDRESS, EMAIL, HPHONE, OPHONE, CPHONE,
			SDATE, PDATE, ADATE, PLACE1, PLACE2, PLACE3, POSITION, DUTIES, JOBTYPE, USERTYPE, 
			SCHOLARSHIP, EXCAREER, EXCAREER1, EXCAREER2, EXCAREER3, USEGRADE, INOUT, COMMENT_, USER_IMG, CDATE
		) 
		VALUES 
		(
			#{userid}, 
	]]>
		<choose>
		<when test="isHashedPasswd eq true">
		<![CDATA[
			#{passwd},
		]]>
		</when>
		<otherwise>
		<![CDATA[
			XX1.ENC_VARCHAR2_INS(#{passwd}, 10, 'SHA256'),
		]]>
		</otherwise>
		</choose>			
	<![CDATA[	 
			#{name}, #{chnname}, #{family}, #{address}, #{email}, #{hphone}, #{ophone}, #{cphone},
			#{sdate}, #{pdate}, #{adate}, #{place1}, #{place2}, #{place3}, #{position}, #{duties}, #{jobtype}, 'g',
			#{scholarship}, #{excareer}, #{excareer1}, #{excareer2}, #{excareer3}, #{usegrade}, #{inout}, #{comment_}, #{userimg,jdbcType=VARCHAR}, NOW()
		)
	]]>
	</insert>		
</mapper>
