<?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="ReportFile">
	
	<resultMap id="reportFileMap" type="reportFileVO">
		<result property="fsSeq" column="fs_seq" />
		<result property="fsFileCount" column="fs_file_count" />
	</resultMap>
	
	<select id="ReportFile.selectFileSeq" resultMap="reportFileMap" >
		<![CDATA[
		SELECT 
			FS_SEQ, FS_FILE_COUNT 
		FROM 
			RPT_FILE_STORAGE 
		WHERE 
			FS_SEQ = (SELECT MAX(FS_SEQ) FROM RPT_FILE_STORAGE)
		]]>
	</select>
	
	<insert id="ReportFile.insertFileSeq">
			INSERT INTO RPT_FILE_STORAGE (FS_FILE_COUNT) VALUES (1)
		<selectKey resultType="int" keyProperty="fsSeq" order="AFTER">
	        SELECT RPT_FILE_STORAGE_FS_SEQ_SEQ.CURRVAL FROM DUAL
	    </selectKey>
	</insert>
	
	<update id="ReportFile.updateFileSeq" parameterType="hashMap">
		<![CDATA[
		UPDATE
			RPT_FILE_STORAGE 
		SET
			FS_FILE_COUNT = FS_FILE_COUNT + #{cnt}
		WHERE 
			FS_SEQ = #{fsseq}
		]]>
	</update>
	
	<update id="ReportFile.insert" parameterType="reportVO" >
		<![CDATA[
			UPDATE 
				RPT_INFO 
			SET
				IN_FSSEQ = #{inFsseq},
				IN_FILE1 = #{inFile1},
				IN_FILE2 = #{inFile2},
				IN_FILE3 = #{inFile3},
				IN_FILE4 = #{inFile4},
				IN_FILE5 = #{inFile5}
			WHERE 
				IN_SEQ = #{inSeq}
		]]>
	</update>
	
</mapper>