<jsp:directive.page pageEncoding="UTF-8" />
<!-- GFM0007 ﾗﾍﾞﾙﾘｿｰｽ ⇒ DB定義(ｶﾗﾑ名)更新 -->

<!-- KBLBL 0:一般 1:ｶﾗﾑ のみ対象とします -->
<og:query command="{@command}" debug="{@debug}" dbid="{@DBID_R}" maxRowCount="0">
	select '1' as WRITABLE, '' as TABLE_NAME,CLM,
			NAME_JA as CLM_NAME,UNIQ,SYSTEM_ID,KBSAKU
	from GEA08
	where SYSTEM_ID in ( '{@SYSTEM_ID_R}','**' )
	<og:where startKey="and">
		<og:and value="CLM like '{@CLM}'"	/>
	</og:where>
	and   LANG	= 'ja'
	and   FGJ	= '1'
	and   KBLBL	in ( '0', '1' )
	order by SYSTEM_ID DESC, KBSAKU DESC, CLM
</og:query>

<!-- GE82 を検索して、一致するﾗﾍﾞﾙを書き換えます(他の差分更新と異なるので注意)。 -->
<!-- KBCLM 6:除外 7:共通 8:有閑 9:削除 は対象外 -->
<og:query command="{@command}" debug="{@debug}" maxRowCount="0" scope="request">
	select '0' as WRITABLE, UPPER(TABLE_NAME) AS TABLE_NAME,UPPER(CLM) AS CLM,
			CLM_NAME,UNIQ,SYSTEM_ID,KBSAKU
	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="KBSAKU		=    '{@KBSAKU}'"	/>
		<og:and value="SUBSYS		like '{@SUBSYS}'"	/>
	</og:where>
	and		KBCLM	< '6'
	and		FGJ		= '1'
	order by TABLE_NAME,SEQNO
</og:query>

<!-- グループ処理では、先行優先 -->
<og:tableMerge
	action        = "DIFFERENCE"
	masterScope   = "session"
	masterKeys    = "CLM"
	diffKeys      = "CLM_NAME"
	modifyClms    = "UNIQ"
	slaveScope    = "request"
	display       = "true"
/>

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

<!-- UNIQ のみでユニークになるが、安全のため、SYSTEM_IDとTBLSYU,CLM だけは条件に加えておく -->
<og:hidden name="SQL">
	UPDATE GE82 SET
			CLM_NAME	= [CLM_NAME],
			DYUPD		= '{@USER.YMDH}',
			USRUPD		= '{@USER.ID}',
			PGUPD		= '{@GUI.KEY}'
	WHERE	UNIQ		= [UNIQ]
	AND		SYSTEM_ID	= '{@SYSTEM_ID_D}'
	AND		TBLSYU		= '{@TBLSYU}'
	AND		UPPER(CLM)	= [CLM]
</og:hidden>
