<jsp:directive.page pageEncoding="UTF-8" />
<!-- ﾗﾍﾞﾙ区分更新 -->
<!-- 画面ﾘｿｰｽの画面ﾚﾍﾞﾙ(GUILVL) が、3:通常,4:通常 の場合は、ﾗﾍﾞﾙ区分(KBLBL)を、3:画面 にし、それ以外は、4:画面分類 にします。 -->
<og:query command="{@command}" debug="{@debug}" maxRowCount="{@maxRowCount}">
	select	A.SYSTEM_ID,A.CLM,A.UNIQ,A.KBLBL as "BEFORE",'{@ARROW}',
			case when B.GUILVL in ('3','4') then '3' else '4' end as KBLBL
	from	GEA08 A inner join GEA11 B
			on  A.CLM = B.GUIKEY
			and case when B.GUILVL in ('3','4') then '3' else '4' end != A.KBLBL
			and B.SYSTEM_ID IN ( '{@SYSTEM_ID}','{@BASE}','{@AST}' )
			and B.FGJ	= '1'
			<og:where startKey="and">
				<og:and value = "B.GUIKEY like '{@CLM}'" />
			</og:where>
	where	A.SYSTEM_ID IN ( '{@SYSTEM_ID}','{@BASE}','{@AST}' )
	and		A.FGJ	= '1'
	union
	select	A.SYSTEM_ID,A.CLM,A.UNIQ,A.KBLBL as "BEFORE",'{@ARROW}','1' as KBLBL
	from	GEA08 A inner join GEA03 B
			on  A.CLM = B.CLM
			and B.SYSTEM_ID IN ( '{@SYSTEM_ID}','{@BASE}','{@AST}' )
			and B.FGJ	= '1'
			<og:where startKey="and">
				<og:and value = "B.CLM like '{@CLM}'" />
			</og:where>
	where	A.SYSTEM_ID IN ( '{@SYSTEM_ID}','{@BASE}','{@AST}' )
	and		A.FGJ	= '1'
	and		A.KBLBL != '1'
	union
	select	A.SYSTEM_ID,A.CLM,A.UNIQ,A.KBLBL as "BEFORE",'{@ARROW}',
			case when A.CLM like 'ERR0%' or A.CLM like A.SYSTEM_ID || 'E0' then '8'
				 when A.CLM like 'MSG0%' or A.CLM like A.SYSTEM_ID || 'M0' then '7' end as KBLBL
	from	GEA08 A
	where	A.SYSTEM_ID IN ( '{@SYSTEM_ID}','{@BASE}','{@AST}' )
	and		case when A.CLM like 'ERR0%' or A.CLM like A.SYSTEM_ID || 'E0' then '8'
				 when A.CLM like 'MSG0%' or A.CLM like A.SYSTEM_ID || 'M0' then '7' end != A.KBLBL
	and    A.FGJ	= '1'
	<og:where startKey="and">
		<og:and value = "A.CLM like '{@CLM}'" />
	</og:where>
	union
	select A.SYSTEM_ID,A.CLM,A.UNIQ,A.KBLBL as "BEFORE",'{@ARROW}','6' as KBLBL
	from GEA08 A inner join GEA04 B
			on  A.CLM = B.CLM || '.' || B.CODE
			and B.SYSTEM_ID IN ( '{@SYSTEM_ID}','{@BASE}','{@AST}' )
			and B.FGJ	= '1'
			<og:where startKey="and">
				<og:and value = "B.CLM like '{@CLM}'" />
			</og:where>
	where	A.SYSTEM_ID IN ( '{@SYSTEM_ID}','{@BASE}','{@AST}' )
	and		A.FGJ	= '1'
	and		A.KBLBL != '6'
	and not ( A.CLM like 'ERR0%' or A.CLM like A.SYSTEM_ID || 'E0' or
			  A.CLM like 'MSG0%' or A.CLM like A.SYSTEM_ID || 'M0' )
	order by 1,2
</og:query>

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

<og:hidden name="SQL">
	UPDATE GEA08 SET
			KBLBL   = [KBLBL],
			DYUPD   = '{@USER.YMDH}',
			USRUPD  = '{@USER.ID}',
			PGUPD   = '{@GUI.KEY}'
	WHERE SYSTEM_ID = [SYSTEM_ID]
	AND   CLM       = [CLM]
	AND   UNIQ      = [UNIQ]
</og:hidden>
