<jsp:directive.page pageEncoding="UTF-8" />
<og:query command="{@command}" debug="{@debug}" maxRowCount="0">
	select	UPPER(TABLE_NAME) AS TABLE_NAME,UPPER(CLM) AS CLM,NAME_JA,CLS_NAME,
			COALESCE(RENDERER,(CASE
						WHEN ( UPPER(CLM) LIKE 'CD%' OR UPPER(CLM) LIKE 'FG%' OR UPPER(CLM) LIKE 'KB%' )
							AND USE_LENGTH <= '2' THEN 'MENU'
						WHEN ( UPPER(CLM) LIKE 'DY%' ) THEN
							CASE WHEN USE_LENGTH = '6'  THEN 'YM'
								 WHEN USE_LENGTH = '8'  THEN 'YMD'
								 WHEN USE_LENGTH = '14' THEN 'YMDH'
							     ELSE 'TEXT'
							END
						ELSE 'LABEL'
						END)
			) AS RENDERER,
			COALESCE(EDITOR,(CASE
						WHEN ( UPPER(CLM) LIKE 'CD%' OR UPPER(CLM) LIKE 'FG%' OR UPPER(CLM) LIKE 'KB%' )
							AND USE_LENGTH <= '2' THEN 'MENU'
						WHEN ( UPPER(CLM) LIKE 'DY%' ) THEN
							CASE WHEN USE_LENGTH = '6'  THEN 'YM'
								 WHEN USE_LENGTH = '8'  THEN 'YMD'
								 WHEN USE_LENGTH = '14' THEN 'YMDH'
							     ELSE 'TEXT'
							END
						ELSE 'TEXT'
						END)
			) AS EDITOR,
			COALESCE(DBTYPE,(CASE 
						WHEN CLS_NAME in ( 'NUMBER','INTEGER' ) THEN 'S9'
						WHEN CLS_NAME LIKE 'VARCHAR%' THEN
							CASE WHEN to_number(USE_LENGTH)  <= 30   THEN 'X'
								 WHEN to_number(USE_LENGTH)  <= 100  THEN 'XK'
								 WHEN to_number(USE_LENGTH)  >  100  THEN 'KX'
							     ELSE 'X'
							END
						ELSE 'X'
						END)
			) AS DBTYPE,
			COALESCE(USE_LENGTH,'10000') AS USE_LENGTH,DATA_DEFAULT,UNIQ,SYSTEM_ID,0 SEQ
	from GF05
	where SYSTEM_ID = '{@SYSTEM_ID_D}'
	and   TBLSYU    = '{@TBLSYU_D}'
	<og:where startKey="and">
		<og:and value="TABLE_NAME like '{@TABLE_NAME_D}%'"	/>
		<og:and value="CLM        like '{@CLM_D}%'"			/>
	</og:where>
	and   KBCLM		<= '7'
	and   FGJ       = '1'
	order by CLM,TABLE_NAME
</og:query>

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

</og:query>

<og:tableMerge
	action        = "MINUS"
	masterScope   = "session"
	masterKeys    = "CLM"
	slaveScope    = "request"
	display       = "true"
/>

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

<og:hidden name="SQL">
	INSERT INTO GEA03
		(SYSTEM_ID,CLM,NAME_JA,CLS_NAME,RENDERER,EDITOR,DBTYPE,
		 USE_LENGTH,DATA_DEFAULT,KBSAKU,
		 FGJ,DYSET,DYUPD,USRSET,USRUPD,PGUPD)
	VALUES
		('{@SYSTEM_ID_R}',[CLM],[NAME_JA],[CLS_NAME],[RENDERER],[EDITOR],[DBTYPE],
		 [USE_LENGTH],[DATA_DEFAULT],'1',
		 '1','{@USER.YMDH}','{@USER.YMDH}','{@USER.ID}','{@USER.ID}','{@GUI.KEY}')
</og:hidden>

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

<!-- ラベルリソース(GEA08) をINSERT するので、既存のリソースを、削除(FGJ='9')する。 -->
<og:hidden name="SQLD2">
	UPDATE GEA08 SET
			FGJ		= '9',
			DYUPD	= '{@USER.YMDH}',
			USRUPD	= '{@USER.ID}',
			PGUPD	= '{@GUI.KEY}'
	WHERE SYSTEM_ID = '{@SYSTEM_ID_R}'
	AND   CLM		= [CLM]
	AND   LANG		= 'ja'
	AND   KBSAKU	!= '0'
</og:hidden>

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