<?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"
	xmlns:fn="http://java.sun.com/jsp/jstl/functions"
	version="2.0">
<jsp:directive.page language="java" contentType="text/html; charset=UTF-8" />

<og:query command="{@command}" displayMsg="" maxRowCount="50000" quotCheck="false">
	select A.{@CLM} KVAL, B.KUID, B.DYKAITO, B.NOKAITO from AN12 A inner join AN11 B
	on A.NOKAITO = B.NOKAITO
	where A.USERID = '{@USER.ID}'
	and A.CDANK = '{@CDANK}'
	and A.CDSITSU = '{@CDSITSU}'
	and A.FGOTHER = '0'
	and A.FGJ = '1'
	order by A.UNIQ DESC
</og:query>

<og:value command="SQL" action="ROW_APPEND">
	select A.UNIQ AN02_OTHER_UNIQS
	from AN02 A
	where A.CDANK = '{@CDANK}'
	and A.CDSITSU != '{@CDSITSU}'
	and A.FGKEY = '1'
	and A.FGJ = '1'
	order by A.SEQNO
</og:value>

<c:forTokens items="${AN02_OTHER_UNIQS}" delims="," var="AN02_OTHER_UNIQ" varStatus="status">
	<og:value command="SQL">
		select A.CDSITSU CDSITSU_OTHER
		from AN02 A
		where A.UNIQ = '{@AN02_OTHER_UNIQ}'
	</og:value>

	<og:query command="{@command}" displayMsg="" notfoundMsg="" maxRowCount="50000" quotCheck="false" scope="request">
		select
			A.NOKAITO
			,case when A.FGOTHER = '0' then KNAME else KVAL end KEY${status.count}
		from AN12 A
		where A.CDANK = '{@CDANK}'
		and A.CDSITSU = '{@CDSITSU_OTHER}'
		and A.FGJ = '1'
	</og:query>

	<og:tableMerge
		command="{@command}"
		action="GROUP"
		display="false"
		masterScope="request"
		scope="request"
		masterKeys="NOKAITO"
		groupAddClms="KEY${status.count}"
		separator="|" />
	<og:tableMerge
		command="{@command}"
		action="UNION_CLM"
		display="false"
		slaveScope="request"
		masterKeys="NOKAITO"
		unionClms="KEY${status.count}" />

</c:forTokens>

<og:forward page="download.jsp" keys="CDANK,CDSITSU,listId" vals="{@CDANK},{@CDSITSU},list" />

</jsp:root>
