<jsp:directive.page pageEncoding="UTF-8" />
<!-- GFM0011 DB定義 ⇒ ｶﾗﾑ･ｶﾗﾑﾘｿｰｽ属性更新 -->

<!-- KBCLM 6:除外 7:共通 8:有閑 9:削除 は対象外 -->
<og:query command="{@command}" debug="{@debug}" maxRowCount="0">
	select	'1' as WRITABLE,UPPER(TABLE_NAME) AS TABLE_NAME,UPPER(CLM) AS CLM,CLM_NAME as NAME_JA,CLS_NAME,
			RENDERER,EDITOR,DBTYPE,RENDERER_PARAM,EDITOR_PARAM,TYPE_PARAM,
			VIEW_LENGTH,USE_LENGTH,DATA_DEFAULT,UNIQ,
			case when SUBSYS='**' then '**' else '{@SYSTEM_ID_R}' end as SYSTEM_ID,KBSAKU,SUBSYS
	from GE82
	where SYSTEM_ID = '{@SYSTEM_ID_D}'
	and   TBLSYU    = '{@TBLSYU}'
	<og:where startKey="and">
		<og:and value="TABLE_NAME	like '{@TABLE_NAME}'"	/>
		<og:and value="CLM			like '{@CLM}'"		/>
		<og:and value="KBSAKU		=    '{@KBSAKU}'"	/>
		<og:and value="SUBSYS		like '{@SUBSYS}'"	/>
	</og:where>
	and		KBCLM	< '6'
	and		FGJ		= '1'
	order by CLM,KBSAKU DESC
</og:query>

<og:query command="{@command}" debug="{@debug}" dbid="{@DBID_R}" maxRowCount="0" scope="request">
	select '0' as WRITABLE,'' as TABLE_NAME,CLM,NAME_JA,CLS_NAME,
			RENDERER,EDITOR,DBTYPE,RENDERER_PARAM,EDITOR_PARAM,TYPE_PARAM,
			VIEW_LENGTH,USE_LENGTH,DATA_DEFAULT,UNIQ,SYSTEM_ID,KBSAKU,SUBSYS
	from GEA03
	where SYSTEM_ID in ( '{@SYSTEM_ID_R}','**' )
	<og:where startKey="and">
		<og:and value="CLM like '{@CLM}'" />
	</og:where>
	and   FGJ       = '1'
	ORDER BY SYSTEM_ID DESC, KBSAKU DESC, CLM
</og:query>

<!-- CLMでグループ処理されます。先行優先 -->
<og:tableMerge
	action        = "DIFFERENCE"
	masterScope   = "session"
	masterKeys    = "CLM"
	diffKeys      = "NAME_JA,CLS_NAME,RENDERER,EDITOR,DBTYPE,RENDERER_PARAM,EDITOR_PARAM,TYPE_PARAM,VIEW_LENGTH,USE_LENGTH,DATA_DEFAULT,KBSAKU,SUBSYS"
	modifyClms    = "UNIQ"
	slaveScope    = "request"
	display       = "true"
/>

<og:value key="lblKey" value="C" />

<!-- UNIQ のみでユニークになるが、安全のため、SYSTEM_IDとCLMだけは条件に加えておく -->
<og:hidden name="SQL">
	UPDATE GEA03 SET
			NAME_JA			= [NAME_JA],
			CLS_NAME		= [CLS_NAME],
			RENDERER		= [RENDERER],
			EDITOR			= [EDITOR],
			DBTYPE			= [DBTYPE],
			RENDERER_PARAM	= [RENDERER_PARAM],
			EDITOR_PARAM	= [EDITOR_PARAM],
			TYPE_PARAM		= [TYPE_PARAM],
			VIEW_LENGTH		= [VIEW_LENGTH],
			USE_LENGTH		= [USE_LENGTH],
			DATA_DEFAULT	= [DATA_DEFAULT],
			KBSAKU			= [KBSAKU],
			SUBSYS			= [SUBSYS],
			DYUPD			= '{@USER.YMDH}',
			USRUPD			= '{@USER.ID}',
			PGUPD			= '{@GUI.KEY}'
	WHERE	UNIQ			= [UNIQ]
	AND		SYSTEM_ID		= [SYSTEM_ID]
	AND		CLM				= [CLM]
</og:hidden>

<og:hidden name="SQL2">
	INSERT INTO GEA08
		(SYSTEM_ID,CLM,NAME_JA,LNAME,KBSAKU,SUBSYS,KBLBL,LANG,
		 FGJ,DYSET,DYUPD,USRSET,USRUPD,PGUPD)
	VALUES
		([SYSTEM_ID],[CLM],[NAME_JA],[NAME_JA],[KBSAKU],[SUBSYS],'1','ja',
		 '1','{@USER.YMDH}','{@USER.YMDH}','{@USER.ID}','{@USER.ID}','{@GUI.KEY}')
</og:hidden>

<!-- ラベルリソース(GEA08) をINSERT するので、重複するリソースを、削除(FGJ='9')する。 -->
<og:hidden name="SQL3">
	UPDATE GEA08 A SET
			A.FGJ		= '9',
			A.DYUPD		= '{@USER.YMDH}',
			A.USRUPD	= '{@USER.ID}',
			A.PGUPD		= '{@GUI.KEY}'
	WHERE	A.SYSTEM_ID	= [SYSTEM_ID]
	AND		A.CLM		= [CLM]
	AND		A.KBSAKU	= [KBSAKU]
	AND		A.LANG		= 'ja'
	AND		exists (select 1 from GEA08 B
					where A.SYSTEM_ID = B.SYSTEM_ID
					and   A.CLM       = B.CLM
					and   A.KBSAKU    = B.KBSAKU
					and   A.LANG      = B.LANG
					and   A.UNIQ      < B.UNIQ
				)
</og:hidden>

<og:hidden name="DBID2" value="{@DBID_R}" />
