<?xml version="1.0" encoding="UTF-8" ?>
<jsp:root
	xmlns:jsp="http://java.sun.com/JSP/Page"
	xmlns:og="hybs-taglib.tld"
	version="2.0">
<jsp:directive.page language="java" contentType="text/html; charset=UTF-8" />

<og:head headType="result" />
<jsp:directive.include file="/jsp/custom/result_info.jsp" />
<og:comment
	system	= "GF:エンジンサンプル"
	pgid	= "GF2060"
	title	= "定義ファイル検証・反映"
	date	= "2008/10/27"
	author	= "Hiroki.Nakamura"
	text	= ""
	version	= "001"
/>

<og:entry command="{@command}" />

<!-- テーブル定義を GF02 テーブルに登録します。 -->
<og:query command="{@command}" debug="{@debug}" >
		delete from GF02 where SYSTEM_ID='{@SYSTEM_ID}' and TBLSYU='{@TBLSYU}'
</og:query>

<og:query command="{@command}" debug="{@debug}" maxRowCount="0">
		select	TABLE_NAME,NAME_JA
		from GF80
		where SYSTEM_ID  = '{@SYSTEM_ID}'
		and   TBLSYU = '{@TBLSYU}'
		and   FGJ	 =  '1'
		group by TABLE_NAME,NAME_JA,SYSTEM_ID
		order by TABLE_NAME
</og:query>

<og:value key="GF02_CNT" value="{@DB.COUNT}" />

<!--
<og:tableUpdate command="ENTRY" queryType="JDBCTableUpdate" selectedAll="true" >
	<og:tableUpdateParam
		constObjKey = "GF"
		sqlType		= "INSERT"
		table		= "GF02"
		constKeys	= "SYSTEM_ID,TBLSYU,SKENSU,JKENSU,TABLESPACE_NAME,INITIAL_EXTENT,INITIAL_AUTO"
		constVals	= "{@SYSTEM_ID},{@TBLSYU},0,0,GETBL01,16,16"
	/>
</og:tableUpdate>
-->

<og:tableUpdate
	selectedAll = "true"
	command		= "ENTRY"
	queryType	= "JDBCTableUpdate" >
	INSERT INTO GF02
		(TABLE_NAME,NAME_JA,SYSTEM_ID,TBLSYU,
		 SKENSU,JKENSU,TABLESPACE_NAME,INITIAL_EXTENT,INITIAL_AUTO,
		 FGJ,DYSET,DYUPD,USRSET,USRUPD,PGUPD)
	VALUES
		([TABLE_NAME],[NAME_JA],'{@SYSTEM_ID}','{@TBLSYU}',
		 0,0,'GETBL01',16,16,
		 '1','{@USER.YMDH}','{@USER.YMDH}','{@USER.ID}','{@USER.ID}','{@GUI.KEY}')
</og:tableUpdate>

<!-- テーブルカラム定義を GF05 テーブルに登録します。 -->
<og:query command="{@command}" debug="{@debug}" >
		delete from GF05 where SYSTEM_ID='{@SYSTEM_ID}' and TBLSYU='{@TBLSYU}'
</og:query>

<og:query command="{@command}" debug="{@debug}" maxRowCount="0">
		select	TABLE_NAME,NAME_JA,CLM,SEQNO,CLM_NAME,CLS_NAME,USE_LENGTH,
				DATA_DEFAULT,NOT_NULL,RENDERER,EDITOR,DBTYPE,KBCLM,BIKO
		from GF80
		where SYSTEM_ID  = '{@SYSTEM_ID}'
		and   TBLSYU = '{@TBLSYU}'
		and   FGJ	 =  '1'
		order by TABLE_NAME,SEQNO
</og:query>

<og:value key="GF05_CNT" value="{@DB.COUNT}" />

<og:tableUpdate
	selectedAll = "true"
	command		= "ENTRY"
	queryType	= "JDBCTableUpdate" >
	INSERT INTO GF05
		(TABLE_NAME,CLM,SEQNO,NAME_JA,CLS_NAME,USE_LENGTH,
		 DATA_DEFAULT,NOT_NULL,RENDERER,EDITOR,DBTYPE,FGCOM,BIKO,SYSTEM_ID,TBLSYU,
		 CDKH,FGJ,DYSET,DYUPD,USRSET,USRUPD,PGUPD)
	VALUES
		([TABLE_NAME],[CLM],[SEQNO],[CLM_NAME],[CLS_NAME],[USE_LENGTH],
		 [DATA_DEFAULT],[NOT_NULL],[RENDERER],[EDITOR],[DBTYPE],[KBCLM],[BIKO],'{@SYSTEM_ID}','{@TBLSYU}',
		 'A','1','{@USER.YMDH}','{@USER.YMDH}','{@USER.ID}','{@USER.ID}','{@GUI.KEY}')
</og:tableUpdate>

<!-- テーブルカラム定義を GF05 テーブルに登録します。 -->
<og:query command="{@command}" debug="{@debug}" >
		delete from GF06 where SYSTEM_ID='{@SYSTEM_ID}' and TBLSYU='{@TBLSYU}'
</og:query>

<og:query command="{@command}" debug="{@debug}" maxRowCount="0">
		select TABLE_NAME,TABLE_NAME || '_UQ' AS INDEX_NAME,'0' AS INDTYPE
		from GF80
		where SYSTEM_ID  = '{@SYSTEM_ID}'
		and   TBLSYU = '{@TBLSYU}'
		and   FGJ	 =  '1'
		and   LENGTH(UK) != 0
		union
		select TABLE_NAME,TABLE_NAME || '_LUQ' AS INDEX_NAME,'1' AS INDTYPE
		from GF80
		where SYSTEM_ID  = '{@SYSTEM_ID}'
		and   TBLSYU = '{@TBLSYU}'
		and   FGJ	 =  '1'
		and   LENGTH(LUK) != 0
		union
		select TABLE_NAME,TABLE_NAME || '_SA' AS INDEX_NAME,'2' AS INDTYPE
		from GF80
		where SYSTEM_ID  = '{@SYSTEM_ID}'
		and   TBLSYU = '{@TBLSYU}'
		and   FGJ	 =  '1'
		and   LENGTH(IXA) != 0
		union
		select TABLE_NAME,TABLE_NAME || '_SB' AS INDEX_NAME,'2' AS INDTYPE
		from GF80
		where SYSTEM_ID  = '{@SYSTEM_ID}'
		and   TBLSYU = '{@TBLSYU}'
		and   FGJ	 =  '1'
		and   LENGTH(IXB) != 0
		union
		select TABLE_NAME,TABLE_NAME || '_SC' AS INDEX_NAME,'2' AS INDTYPE
		from GF80
		where SYSTEM_ID  = '{@SYSTEM_ID}'
		and   TBLSYU = '{@TBLSYU}'
		and   FGJ	 =  '1'
		and   LENGTH(IXC) != 0
		union
		select TABLE_NAME,TABLE_NAME || '_SD' AS INDEX_NAME,'2' AS INDTYPE
		from GF80
		where SYSTEM_ID  = '{@SYSTEM_ID}'
		and   TBLSYU = '{@TBLSYU}'
		and   FGJ	 =  '1'
		and   LENGTH(IXD) != 0
		union
		select TABLE_NAME,TABLE_NAME || '_SE' AS INDEX_NAME,'2' AS INDTYPE
		from GF80
		where SYSTEM_ID  = '{@SYSTEM_ID}'
		and   TBLSYU = '{@TBLSYU}'
		and   FGJ	 =  '1'
		and   LENGTH(IXE) != 0
		union
		select TABLE_NAME,TABLE_NAME || '_SF' AS INDEX_NAME,'2' AS INDTYPE
		from GF80
		where SYSTEM_ID  = '{@SYSTEM_ID}'
		and   TBLSYU = '{@TBLSYU}'
		and   FGJ	 =  '1'
		and   LENGTH(IXF) != 0
		union
		select TABLE_NAME,TABLE_NAME || '_SG' AS INDEX_NAME,'2' AS INDTYPE
		from GF80
		where SYSTEM_ID  = '{@SYSTEM_ID}'
		and   TBLSYU = '{@TBLSYU}'
		and   FGJ	 =  '1'
		and   LENGTH(IXG) != 0
		union
		select TABLE_NAME,TABLE_NAME || '_SH' AS INDEX_NAME,'2' AS INDTYPE
		from GF80
		where SYSTEM_ID  = '{@SYSTEM_ID}'
		and   TBLSYU = '{@TBLSYU}'
		and   FGJ	 =  '1'
		and   LENGTH(IXH) != 0
		union
		select TABLE_NAME,TABLE_NAME || '_SI' AS INDEX_NAME,'2' AS INDTYPE
		from GF80
		where SYSTEM_ID  = '{@SYSTEM_ID}'
		and   TBLSYU = '{@TBLSYU}'
		and   FGJ	 =  '1'
		and   LENGTH(IXI) != 0
		union
		select TABLE_NAME,TABLE_NAME || '_SJ' AS INDEX_NAME,'2' AS INDTYPE
		from GF80
		where SYSTEM_ID  = '{@SYSTEM_ID}'
		and   TBLSYU = '{@TBLSYU}'
		and   FGJ	 =  '1'
		and   LENGTH(IXJ) != 0
		union
		select TABLE_NAME,TABLE_NAME || '_SK' AS INDEX_NAME,'2' AS INDTYPE
		from GF80
		where SYSTEM_ID  = '{@SYSTEM_ID}'
		and   TBLSYU = '{@TBLSYU}'
		and   FGJ	 =  '1'
		and   LENGTH(IXK) != 0
		order by TABLE_NAME,INDTYPE,INDEX_NAME
</og:query>

<og:value key="GF06_CNT" value="{@DB.COUNT}" />

<og:tableUpdate
	selectedAll = "true"
	command		= "ENTRY"
	queryType	= "JDBCTableUpdate" >
	INSERT INTO GF06
		(TABLE_NAME,INDEX_NAME,NAME_JA,INDTYPE,TABLESPACE_NAME,
		 INITIAL_AUTO,INITIAL_EXTENT,SYSTEM_ID,TBLSYU,
		 FGJ,DYSET,DYUPD,USRSET,USRUPD,PGUPD)
	VALUES
		([TABLE_NAME],[INDEX_NAME],null,[INDTYPE],'GEIDX01',
		  16,16,'{@SYSTEM_ID}','{@TBLSYU}',
		 '1','{@USER.YMDH}','{@USER.YMDH}','{@USER.ID}','{@USER.ID}','{@GUI.KEY}')
</og:tableUpdate>

<!-- テーブルカラム定義を GF05 テーブルに登録します。 -->
<og:query command="{@command}" debug="{@debug}" >
		delete from GF07 where SYSTEM_ID='{@SYSTEM_ID}' and TBLSYU='{@TBLSYU}'
</og:query>

<og:query command="{@command}" debug="{@debug}" maxRowCount="0">
		select TABLE_NAME,TABLE_NAME || '_UQ' AS INDEX_NAME,CLM,UK AS SEQNO
		from GF80
		where SYSTEM_ID  = '{@SYSTEM_ID}'
		and   TBLSYU = '{@TBLSYU}'
		and   FGJ	 =  '1'
		and   LENGTH(UK) != 0
		union
		select TABLE_NAME,TABLE_NAME || '_LUQ' AS INDEX_NAME,CLM,LUK AS SEQNO
		from GF80
		where SYSTEM_ID  = '{@SYSTEM_ID}'
		and   TBLSYU = '{@TBLSYU}'
		and   FGJ	 =  '1'
		and   LENGTH(LUK) != 0
		union
		select TABLE_NAME,TABLE_NAME || '_SA' AS INDEX_NAME,CLM,IXA AS SEQNO
		from GF80
		where SYSTEM_ID  = '{@SYSTEM_ID}'
		and   TBLSYU = '{@TBLSYU}'
		and   FGJ	 =  '1'
		and   LENGTH(IXA) != 0
		union
		select TABLE_NAME,TABLE_NAME || '_SB' AS INDEX_NAME,CLM,IXB AS SEQNO
		from GF80
		where SYSTEM_ID  = '{@SYSTEM_ID}'
		and   TBLSYU = '{@TBLSYU}'
		and   FGJ	 =  '1'
		and   LENGTH(IXB) != 0
		union
		select TABLE_NAME,TABLE_NAME || '_SC' AS INDEX_NAME,CLM,IXC AS SEQNO
		from GF80
		where SYSTEM_ID  = '{@SYSTEM_ID}'
		and   TBLSYU = '{@TBLSYU}'
		and   FGJ	 =  '1'
		and   LENGTH(IXC) != 0
		union
		select TABLE_NAME,TABLE_NAME || '_SD' AS INDEX_NAME,CLM,IXD AS SEQNO
		from GF80
		where SYSTEM_ID  = '{@SYSTEM_ID}'
		and   TBLSYU = '{@TBLSYU}'
		and   FGJ	 =  '1'
		and   LENGTH(IXD) != 0
		union
		select TABLE_NAME,TABLE_NAME || '_SE' AS INDEX_NAME,CLM,IXE AS SEQNO
		from GF80
		where SYSTEM_ID  = '{@SYSTEM_ID}'
		and   TBLSYU = '{@TBLSYU}'
		and   FGJ	 =  '1'
		and   LENGTH(IXE) != 0
		union
		select TABLE_NAME,TABLE_NAME || '_SF' AS INDEX_NAME,CLM,IXF AS SEQNO
		from GF80
		where SYSTEM_ID  = '{@SYSTEM_ID}'
		and   TBLSYU = '{@TBLSYU}'
		and   FGJ	 =  '1'
		and   LENGTH(IXF) != 0
		union
		select TABLE_NAME,TABLE_NAME || '_SG' AS INDEX_NAME,CLM,IXG AS SEQNO
		from GF80
		where SYSTEM_ID  = '{@SYSTEM_ID}'
		and   TBLSYU = '{@TBLSYU}'
		and   FGJ	 =  '1'
		and   LENGTH(IXG) != 0
		union
		select TABLE_NAME,TABLE_NAME || '_SH' AS INDEX_NAME,CLM,IXH AS SEQNO
		from GF80
		where SYSTEM_ID  = '{@SYSTEM_ID}'
		and   TBLSYU = '{@TBLSYU}'
		and   FGJ	 =  '1'
		and   LENGTH(IXH) != 0
		union
		select TABLE_NAME,TABLE_NAME || '_SI' AS INDEX_NAME,CLM,IXI AS SEQNO
		from GF80
		where SYSTEM_ID  = '{@SYSTEM_ID}'
		and   TBLSYU = '{@TBLSYU}'
		and   FGJ	 =  '1'
		and   LENGTH(IXI) != 0
		union
		select TABLE_NAME,TABLE_NAME || '_SJ' AS INDEX_NAME,CLM,IXJ AS SEQNO
		from GF80
		where SYSTEM_ID  = '{@SYSTEM_ID}'
		and   TBLSYU = '{@TBLSYU}'
		and   FGJ	 =  '1'
		and   LENGTH(IXJ) != 0
		union
		select TABLE_NAME,TABLE_NAME || '_SK' AS INDEX_NAME,CLM,IXK AS SEQNO
		from GF80
		where SYSTEM_ID  = '{@SYSTEM_ID}'
		and   TBLSYU = '{@TBLSYU}'
		and   FGJ	 =  '1'
		and   LENGTH(IXK) != 0
		order by TABLE_NAME,INDEX_NAME,SEQNO
</og:query>

<og:value key="GF07_CNT" value="{@DB.COUNT}" />

<og:tableUpdate
	selectedAll = "true"
	command		= "ENTRY"
	queryType	= "JDBCTableUpdate" >
	INSERT INTO GF07
		(TABLE_NAME,INDEX_NAME,CLM,SEQNO,SYSTEM_ID,TBLSYU,
		 FGJ,DYSET,DYUPD,USRSET,USRUPD,PGUPD)
	VALUES
		([TABLE_NAME],[INDEX_NAME],[CLM],[SEQNO],'{@SYSTEM_ID}','{@TBLSYU}',
		 '1','{@USER.YMDH}','{@USER.YMDH}','{@USER.ID}','{@USER.ID}','{@GUI.KEY}')
</og:tableUpdate>


<!-- TABLE_NAME,INDEX_NAME でユニークになるように、データをマージします。 -->
<og:tableMerge action="GROUP" masterKeys="TABLE_NAME,INDEX_NAME" groupAddClms="CLM" />

<og:tableUpdate command="ENTRY" sqlType="MODIFY" selectedAll="true" queryType="JDBCTableUpdate" debug="{@debug}" displayMsg="MSG0040">
	<og:tableUpdateParam
		constObjKey = "GF"
		sqlType		= "MODIFY"
		table		= "GF06"
		names		= "BIKO"
		asNames		= "CLM"
		orgNames	= "BIKO"
		where		= "SYSTEM_ID='{@SYSTEM_ID}' AND TBLSYU='{@TBLSYU}' AND TABLE_NAME=[TABLE_NAME] AND INDEX_NAME=[INDEX_NAME]"
	/>
</og:tableUpdate>

<!--
<og:query command="NEW" debug="{@debug}" maxRowCount="0">
		SELECT SYSTEM_ID,TBLSYU,TABLE_NAME,INDEX_NAME,'' as BIKO,UNIQ
		FROM GF06
		WHERE SYSTEM_ID = '{@SYSTEM_ID}'
		AND   TBLSYU    = '{@TBLSYU}'
	<og:where startKey="and">
		<og:and value = "TABLE_NAME like '{@TABLE_NAME}%'" />
	</og:where>
</og:query>

<og:tableFilter
	classId	= "DBSELECT"
	keys	= "APPEND"
	vals	= "true"
	selectedAll	= "true" >
		SELECT CLM as BIKO
		FROM GF07
		WHERE SYSTEM_ID	= '{@SYSTEM_ID}'
		AND TBLSYU		= '{@TBLSYU}'
		AND TABLE_NAME	= [TABLE_NAME]
		AND INDEX_NAME	= [INDEX_NAME]
		AND FGJ = '1'
		ORDER BY SEQNO
</og:tableFilter>

<og:tableUpdate
	selectedAll = "true"
	command		= "ENTRY"
	queryType	= "JDBCTableUpdate" >
		UPDATE GF06 SET
			BIKO   = [BIKO]
		WHERE UNIQ = [UNIQ]
</og:tableUpdate>
-->

<og:text>
<table>
  <colgroup class="X" /><colgroup class="X" /><colgroup class="S9" /><colgroup class="X" />
  <tr><td>{@LBL.GF02}</td><td> </td><td>{@GF02_CNT}</td><td>{@LBL.MSG0040}</td></tr>
  <tr><td>{@LBL.GF05}</td><td> </td><td>{@GF05_CNT}</td><td>{@LBL.MSG0040}</td></tr>
  <tr><td>{@LBL.GF06}</td><td> </td><td>{@GF06_CNT}</td><td>{@LBL.MSG0040}</td></tr>
  <tr><td>{@LBL.GF07}</td><td> </td><td>{@GF07_CNT}</td><td>{@LBL.MSG0040}</td></tr>
</table>
</og:text>

<jsp:directive.include file="/jsp/common/htmlend.jsp" />
</jsp:root>
