<?xml version="1.0" encoding="UTF-8" ?>
<jsp:root
	xmlns:jsp="http://java.sun.com/JSP/Page"
	xmlns:og="hybs-taglib.tld"
	xmlns:c="http://java.sun.com/jsp/jstl/core"
	version="2.0">
<jsp:directive.page language="java" contentType="text/html; charset=UTF-8" />

<og:value command="SET" key="seq" value="{@seq}" />

<!-- newDiv -->
<og:equals val1="{@execType}" val2="0">
	<og:equals val1="{@init}" val2="true" notEquals="true">
		<og:value command="SQL" dbid="{@SYS.DEV_DBID}">
			select coalesce(max(SEQ),0) + 100 SEQ
			from GF92
			where SYSTEM_ID = '{@systemId}'
			and PGID = '{@pgId}'
			and NMSYORI = 'JOIN'
		</og:value>

		<c:set var="seq" value="${SEQ-SEQ%100+10}" />
	</og:equals>

	<c:set var="divSeq" value="${seq-seq%100}" />

	<og:text>
	<div joinId="{@joinId}" seq="{@divSeq}" class="divJoin">
		<p class="selTitle ptitle"><span class="close" title="{@LBL.CLOSE}">{@LBL.CLOSEBUTTON}</span>{@LBL.JOINCNDTN}</p>
		<table><tr>
			<td position="left">
				<p class="selTitle ptitle" title="{@tableName}"><span class="astable">({@asTable})</span>{@tableName}</p>
				<table joinId="{@joinId}" tableId="{@tableId}" asTable="{@asTable}">
					<tr><td column="{@column}" title="{@columnName}" seq="{@seq}">{@columnName}</td></tr>
				</table>
			</td>
			<td position="right">
			</td>
		</tr></table>
	</div>
	</og:text>

	<og:equals val1="{@init}" val2="true" notEquals="true">
		<og:query displayMsg="" notfoundMsg="" dbid="{@SYS.DEV_DBID}">
			insert into GF92(
				SYSTEM_ID, PGID, TABLE_NAME, AS_TABLE, CLM, JOINTYPE, NMSYORI, SEQ, ZOKUSEI
			) values (
				'{@systemId}', '{@pgId}', '{@tableId}', '{@asTable}', '{@column}', '1', 'JOIN', {@seq}, {@joinId}
			)
		</og:query>
	</og:equals>
</og:equals>

<!-- newTable -->
<og:equals val1="{@execType}" val2="1">
	<og:text>
		<p class="selTitle ptitle" title="{@tableName}"><span class="astable">({@asTable})</span>{@tableName}</p>
		<table joinId="{@joinId}" tableId="{@tableId}" asTable="{@asTable}">
			<tr><td column="{@column}" title="{@columnName}" seq="{@seq}">{@columnName}</td></tr>
		</table>
	</og:text>

	<og:equals val1="{@init}" val2="true" notEquals="true">
		<og:query displayMsg="" notfoundMsg="" dbid="{@SYS.DEV_DBID}">
			update GF92 set
				ZOKUSEI = '{@joinId}__{@tableId}__{@asTable}.{@column}'
			where SYSTEM_ID = '{@systemId}'
			and PGID = '{@pgId}'
			and TABLE_NAME = '{@otherTableId}'
			and AS_TABLE = '{@otherAsTable}'
			and CLM = '{@otherColumn}'
			and ZOKUSEI like '{@joinId}%'
			and NMSYORI = 'JOIN'
		</og:query>
	</og:equals>
</og:equals>

<!-- newColumn -->
<og:equals val1="2|3" val2="{@execType}" contains="true">
	<og:equals val1="{@init}" val2="true" notEquals="true">
		<og:equals val1="{@execType}" val2="2">
			<og:value command="SQL" dbid="{@SYS.DEV_DBID}">
				select coalesce(max(SEQ),0) + 10 SEQ
				from GF92
				where SYSTEM_ID = '{@systemId}'
				and PGID = '{@pgId}'
				and ZOKUSEI like '{@joinId}%'
				and NMSYORI = 'JOIN'
			</og:value>

			<og:value command="SET" key="seq" value="{@SEQ}" />
		</og:equals>
	</og:equals>

	<og:text>
		<tr><td column="{@column}" title="{@columnName}" seq="{@seq}">{@columnName}</td></tr>
	</og:text>

	<og:equals val1="{@init}" val2="true" notEquals="true">
		<og:equals val1="{@execType}" val2="2">
			<og:query displayMsg="" notfoundMsg="" dbid="{@SYS.DEV_DBID}">
				insert into GF92(
					SYSTEM_ID, PGID, TABLE_NAME, AS_TABLE, CLM, JOINTYPE, NMSYORI, SEQ, ZOKUSEI
				) values (
					'{@systemId}', '{@pgId}', '{@tableId}', '{@asTable}', '{@column}', '1', 'JOIN', {@SEQ}, '{@joinId}'
				)
			</og:query>
		</og:equals>

		<og:equals val1="{@execType}" val2="3">
			<og:query displayMsg="" notfoundMsg="" dbid="{@SYS.DEV_DBID}">
				update GF92 set
					ZOKUSEI = '{@joinId}__{@tableId}__{@asTable}.{@column}'
				where SYSTEM_ID = '{@systemId}'
				and PGID = '{@pgId}'
				and TABLE_NAME = '{@otherTableId}'
				and AS_TABLE = '{@otherAsTable}'
				and CLM = '{@otherColumn}'
				and ZOKUSEI like '{@joinId}%'
				and NMSYORI = 'JOIN'
			</og:query>
		</og:equals>
	</og:equals>
</og:equals>

<!-- remove -->
<og:equals val1="{@execType}" val2="9">
	<og:query displayMsg="" notfoundMsg="" dbid="{@SYS.DEV_DBID}">
		delete from GF92
		where SYSTEM_ID = '{@systemId}'
		and PGID = '{@pgId}'
		and ZOKUSEI like '{@joinId}%'
		and NMSYORI = 'JOIN'
	</og:query>
</og:equals>

</jsp:root>
