<?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.com.mtdata.comtrls.mapper.ComtrlsdataMapper">

	<insert id="insertComtrlsMetadataInfo" parameterType="ComtrlsMetaDataVO">
		<selectKey resultType="int" keyProperty="rlsDataId" order="BEFORE">
			SELECT nextval('comtrlstrgtmetadata_rls_data_id_seq') as rlsDataId
		</selectKey>
		insert into comtrlstrgtmetadata (rls_data_id,
		                                 rls_data_nm,
		                                 rls_data_dc,
		                                 rls_data_aplcnt_id,
		                                 rls_data_rvw_id,
		                                 rls_data_mng_dept_id,
		                                 rls_data_src_inst_id,
		                                 reg_dt,
		                                 crt_ymd,
		                                 rls_data_stts_chg,
		                                 rls_yn)
		values (
		#{rlsDataId},
		#{rlsDataNm},
		#{rlsDataDc},
		#{rlsDataAplcntId},
		#{rlsDataRvwId},
		#{rlsDataMngDeptId},
		#{rlsDataSrcInstId},
		CURRENT_TIMESTAMP,
		#{crt_ymd},
		#{rlsDataSttsChg},
		#{rlsYn})
	</insert>

	<insert id="insertComtrlsSrcdata" parameterType="ComtrlsSrcdataVO">
		<selectKey resultType="int" keyProperty="rlsDataVlId" order="BEFORE">
			SELECT nextval('comtrlsdata_rls_data_vl_id_seq') as rlsDataVlId
		</selectKey>
		insert into comtrlsdata (rls_data_vl_id, rls_data_id, rls_data_vl)
		values (#{rlsDataVlId}, #{rlsDataId},  ( (#{rlsDataVl})::jsonb ) )
	</insert>

	<insert id="insertComtSrcCol" parameterType="ComtrlsColVO">
		<selectKey resultType="int" keyProperty="rlsDataColId" order="BEFORE">
			SELECT nextval('comtrlsdatacol_rls_data_col_id_seq') as rlsDataColId
		</selectKey>
		insert into comtrlsdatacol (rls_data_col_id, rls_data_id, rls_data_col_nm)
		values (#{rlsDataColId}, #{rlsDataId}, #{rlsDataColNm} )
	</insert>

</mapper>
