<?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}" >
	<jsp:text>
		delete from GF02 where SYSTEM_ID = '{@SYSTEM_ID}' and TBLSYU = '3'
	</jsp:text>
</og:query>

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

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

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

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

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

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

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

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

<og:query command="{@command}" debug="{@debug}" maxRowCount="100000">
	<jsp:text>
		select TABLE_NAME,TABLE_NAME || '_UQ' AS INDEX_NAME,'1' AS INDTYPE,SYSTEM_ID
		from GF80
		where SYSTEM_ID  = '{@SYSTEM_ID}'
		and   TBLSYU = '3'
		and   FGJ in ('0','1')
		and   LENGTH(UK) != 0
		union
		select TABLE_NAME,TABLE_NAME || '_SA' AS INDEX_NAME,'2' AS INDTYPE,SYSTEM_ID
		from GF80
		where SYSTEM_ID  = '{@SYSTEM_ID}'
		and   TBLSYU = '3'
		and   FGJ in ('0','1')
		and   LENGTH(IXA) != 0
		union
		select TABLE_NAME,TABLE_NAME || '_SB' AS INDEX_NAME,'2' AS INDTYPE,SYSTEM_ID
		from GF80
		where SYSTEM_ID  = '{@SYSTEM_ID}'
		and   TBLSYU = '3'
		and   FGJ in ('0','1')
		and   LENGTH(IXB) != 0
		union
		select TABLE_NAME,TABLE_NAME || '_SC' AS INDEX_NAME,'2' AS INDTYPE,SYSTEM_ID
		from GF80
		where SYSTEM_ID  = '{@SYSTEM_ID}'
		and   TBLSYU = '3'
		and   FGJ in ('0','1')
		and   LENGTH(IXC) != 0
		union
		select TABLE_NAME,TABLE_NAME || '_SD' AS INDEX_NAME,'2' AS INDTYPE,SYSTEM_ID
		from GF80
		where SYSTEM_ID  = '{@SYSTEM_ID}'
		and   TBLSYU = '3'
		and   FGJ in ('0','1')
		and   LENGTH(IXD) != 0
		union
		select TABLE_NAME,TABLE_NAME || '_SE' AS INDEX_NAME,'2' AS INDTYPE,SYSTEM_ID
		from GF80
		where SYSTEM_ID  = '{@SYSTEM_ID}'
		and   TBLSYU = '3'
		and   FGJ in ('0','1')
		and   LENGTH(IXE) != 0
		union
		select TABLE_NAME,TABLE_NAME || '_SF' AS INDEX_NAME,'2' AS INDTYPE,SYSTEM_ID
		from GF80
		where SYSTEM_ID  = '{@SYSTEM_ID}'
		and   TBLSYU = '3'
		and   FGJ in ('0','1')
		and   LENGTH(IXF) != 0
		union
		select TABLE_NAME,TABLE_NAME || '_SG' AS INDEX_NAME,'2' AS INDTYPE,SYSTEM_ID
		from GF80
		where SYSTEM_ID  = '{@SYSTEM_ID}'
		and   TBLSYU = '3'
		and   FGJ in ('0','1')
		and   LENGTH(IXG) != 0
		order by TABLE_NAME,INDTYPE,INDEX_NAME
  </jsp:text>
</og:query>

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

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

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

<og:query command="{@command}" debug="{@debug}" maxRowCount="100000">
	<jsp:text>
		select TABLE_NAME,TABLE_NAME || '_UQ' AS INDEX_NAME,CLM,UK AS SEQNO,SYSTEM_ID
		from GF80
		where SYSTEM_ID  = '{@SYSTEM_ID}'
		and   TBLSYU = '3'
		and   FGJ in ('0','1')
		and   LENGTH(UK) != 0
		union
		select TABLE_NAME,TABLE_NAME || '_SA' AS INDEX_NAME,CLM,IXA AS SEQNO,SYSTEM_ID
		from GF80
		where SYSTEM_ID  = '{@SYSTEM_ID}'
		and   TBLSYU = '3'
		and   FGJ in ('0','1')
		and   LENGTH(IXA) != 0
		union
		select TABLE_NAME,TABLE_NAME || '_SB' AS INDEX_NAME,CLM,IXB AS SEQNO,SYSTEM_ID
		from GF80
		where SYSTEM_ID  = '{@SYSTEM_ID}'
		and   TBLSYU = '3'
		and   FGJ in ('0','1')
		and   LENGTH(IXB) != 0
		union
		select TABLE_NAME,TABLE_NAME || '_SC' AS INDEX_NAME,CLM,IXC AS SEQNO,SYSTEM_ID
		from GF80
		where SYSTEM_ID  = '{@SYSTEM_ID}'
		and   TBLSYU = '3'
		and   FGJ in ('0','1')
		and   LENGTH(IXC) != 0
		union
		select TABLE_NAME,TABLE_NAME || '_SD' AS INDEX_NAME,CLM,IXD AS SEQNO,SYSTEM_ID
		from GF80
		where SYSTEM_ID  = '{@SYSTEM_ID}'
		and   TBLSYU = '3'
		and   FGJ in ('0','1')
		and   LENGTH(IXD) != 0
		union
		select TABLE_NAME,TABLE_NAME || '_SE' AS INDEX_NAME,CLM,IXE AS SEQNO,SYSTEM_ID
		from GF80
		where SYSTEM_ID  = '{@SYSTEM_ID}'
		and   TBLSYU = '3'
		and   FGJ in ('0','1')
		and   LENGTH(IXE) != 0
		union
		select TABLE_NAME,TABLE_NAME || '_SF' AS INDEX_NAME,CLM,IXF AS SEQNO,SYSTEM_ID
		from GF80
		where SYSTEM_ID  = '{@SYSTEM_ID}'
		and   TBLSYU = '3'
		and   FGJ in ('0','1')
		and   LENGTH(IXF) != 0
		union
		select TABLE_NAME,TABLE_NAME || '_SG' AS INDEX_NAME,CLM,IXG AS SEQNO,SYSTEM_ID
		from GF80
		where SYSTEM_ID  = '{@SYSTEM_ID}'
		and   TBLSYU = '3'
		and   FGJ in ('0','1')
		and   LENGTH(IXG) != 0
		order by TABLE_NAME,INDEX_NAME,SEQNO
  </jsp:text>
</og:query>

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

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

<og:query command="NEW" debug="{@debug}" maxRowCount="{@maxRowCount}">
	<jsp:text>
		SELECT SYSTEM_ID,TBLSYU,TABLE_NAME,INDEX_NAME,'' BIKO,UNIQ
		FROM GF06
		WHERE SYSTEM_ID = '{@SYSTEM_ID}'
		AND   TBLSYU    = '3'
	</jsp:text>
	<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 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" >
	<jsp:text>
		UPDATE GF06 SET
			BIKO = [BIKO]
		WHERE UNIQ = [UNIQ]
	</jsp:text>
</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>
