<?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: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,PRGUPD)
	VALUES
		('3',[TABLE_NAME],[NAME_JA],0,0,'GMIS01',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: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,PRGUPD)
	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   ( UK is not null and UK != '' )
		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   ( IXA is not null and IXA != '' )
		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   ( IXB is not null and IXB != '' )
		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   ( IXC is not null and IXC != '' )
		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   ( IXD is not null and IXD != '' )
		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   ( IXE is not null and IXE != '' )
		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   ( IXF is not null and IXF != '' )
		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   ( IXG is not null and IXG != '' )
		order by TABLE_NAME,INDTYPE,INDEX_NAME
  </jsp:text>
</og:query>

<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,PRGUPD)
	VALUES
		('3',[TABLE_NAME],[INDEX_NAME],null,[INDTYPE],'GMIS02',
		  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   ( UK is not null and UK != '' )
		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   ( IXA is not null and IXA != '' )
		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   ( IXB is not null and IXB != '' )
		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   ( IXC is not null and IXC != '' )
		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   ( IXD is not null and IXD != '' )
		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   ( IXE is not null and IXE != '' )
		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   ( IXF is not null and IXF != '' )
		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   ( IXG is not null and IXG != '' )
		order by TABLE_NAME,INDEX_NAME,SEQNO
  </jsp:text>
</og:query>

<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,PRGUPD)
	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>

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