<jsp:directive.page pageEncoding="UTF-8" />
<og:query command="{@command}" debug="{@debug}" maxRowCount="0" stopZero="true">
	select	case count(*) when 1 then 'true' else 'false' end as WRITABLE ,
			CLM,CLM_NAME,
			count(*) AS CNT, SYSTEM_ID,'' AS UNIQ,'1' AS FGJ,
			LISTAGG(TABLE_NAME, ''',''') WITHIN GROUP (ORDER BY TABLE_NAME, TABLE_NAME) as TABLE_NAME
	from GE82
	where SYSTEM_ID  = '{@SYSTEM_ID}'
	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     <= '7'
	and   FGJ		= '1'
	and (
		CLM in (
			select CLM from (
				select	CLM
				from GE82
				where SYSTEM_ID  = '{@SYSTEM_ID}'
				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     <= '7'
				and   FGJ		= '1'
				group by CLM,CLM_NAME
			) B
			group by CLM
			having count(*) > 1
		)
	--	or	regexp_instr( CLM_NAME , '[０-９Ａ-Ｚａ-ｚァ-ヶ]' ) > 0
		or	regexp_instr( CLM_NAME , '[０-９Ａ-Ｚａ-ｚ]' ) > 0
	)
	group by CLM,CLM_NAME,SYSTEM_ID
	order by CLM,CNT,SYSTEM_ID,TABLE_NAME
</og:query>

<og:viewLink command="{@command}">
	<og:link column="CLM" href="result.jsp" target="RESULT"
		keys="command,ACTION,SYSTEM_ID,TBLSYU,TABLE_NAME,CLM"
		vals="NEW,GFM0036B,{@SYSTEM_ID},{@TBLSYU},[TABLE_NAME],[CLM]" />
</og:viewLink>

<og:hidden name="SQL" >
	UPDATE GE82 SET
			CLM_NAME 	= [CLM_NAME],
			COMMENTS	= '{@DATE.YMDF} {@LBL.@ACTION}',
			CDKH		= 'C',
			DYUPD		= '{@USER.YMDH}',
			USRUPD		= '{@USER.ID}',
			PGUPD		= '{@GUI.KEY}'
	WHERE SYSTEM_ID	= '{@SYSTEM_ID}'
	AND TBLSYU		= '{@TBLSYU}'
	AND TABLE_NAME  = [TABLE_NAME]
	AND CLM			= [CLM]
</og:hidden>

<og:hidden name="noWritable">SYSTEM_ID,CLM,CNT,TABLE_NAME</og:hidden>