<jsp:directive.page pageEncoding="UTF-8" />
<!-- GFM0012 ｺｰﾄﾞﾘｿｰｽ ⇒ DB定義(備考)更新 -->

<og:query command="{@command}" debug="{@debug}" dbid="{@DBID_R}" maxRowCount="0">
	select '1' as WRITABLE,'' as TABLE_NAME,CLM,NAME_JA,'' as BIKO,UNIQ,SYSTEM_ID
	from GEA03
	where SYSTEM_ID in ( '{@SYSTEM_ID_R}','**' )
	<og:where startKey="and">
		<og:and value="CLM like '{@CLM}'" />
	</og:where>
	and   FGJ       = '1'
	and   ( EDITOR = 'MENU' OR RENDERER = 'MENU' )
	ORDER BY SYSTEM_ID DESC, KBSAKU DESC, CLM
</og:query>

<og:tableFilter classId="DBSELECT" dbid="{@DBID_R}" keys="APPEND" vals="true" selectedAll="true" >
	select CASE
			WHEN B.LNAME LIKE '%:%' THEN B.LNAME
			ELSE A.CODE||':'||B.LNAME END BIKO
	from GEA04 A inner join GEA08 B
		on  A.SYSTEM_ID		= B.SYSTEM_ID
		and A.CLM||'.'||A.CODE = B.CLM
		and A.FGJ			= B.FGJ
	where A.SYSTEM_ID = [SYSTEM_ID]
	and A.CLM = [CLM]
	and A.FGJ = '1'
	and B.LANG = 'ja'
	order by A.CLM,A.SEQNO
</og:tableFilter>

<!-- 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,BIKO,UNIQ,SYSTEM_ID
	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:where>
	and		KBCLM	< '6'
	and		FGJ		= '1'
	and   ( EDITOR = 'MENU' OR RENDERER = 'MENU' )
	order by CLM,TABLE_NAME
</og:query>

<og:tableMerge
	action        = "DIFFERENCE"
	masterScope   = "session"
	masterKeys    = "CLM"
	diffKeys      = "BIKO"
	modifyClms    = "UNIQ"
	slaveScope    = "request"
	display       = "true"
/>

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

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