/*******************************************************************************
*	 All Rights reserved,Copyright (c) K-Opticom 
********************************************************************************
*＜プログラム内容＞
*	システム名		：eo顧客基幹システム
*	モジュール名	：JSYejbKK0271KRCK
*	ソースファイル名：JSYejbKK0271KRCK.java
*	作成者			：EK911015
*	日付			：2012年06月28日
*＜機能概要＞
*	関連チェック部品です。
*＜修正履歴＞
*	バージョン	修正日		修正者		修正内容
*	ｖ1.00.00
*
********************************************************************************/

package eo.ejb.cbm.entity;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.text.ParsePosition;
import com.fujitsu.futurity.model.ejb.common.JSYejbLog;
import com.fujitsu.futurity.model.ejb.common.JSYejbConnection;
import com.fujitsu.futurity.model.ejb.common.StatusCodes;
import com.fujitsu.futurity.model.ejb.common.fw.AgentDispatchContext;
import eo.ejb.common.EventIDList;
import com.fujitsu.futurity.model.ejb.common.fw.KanrenCheckHandler;
import eo.ejb.common.JPCModelCommon;

import com.fujitsu.futurity.model.base.CAANConnectionMgr;
import com.fujitsu.futurity.model.base.CAANJDBCUtil;
import com.fujitsu.futurity.model.base.CAANMsg;
import com.fujitsu.futurity.model.base.CAANRuntimeException;

/**
 * 面開発案件関連チェッククラスです。
 * ＜メソッド一覧＞
 * invoke
 *	execIKK0081D003_7
 *	execIKK0081D005_7
 *	execIKK0081D008_7
 *	execIKK0081D013_5
 *	execIKK0081D017_6
 *	execIKK0081D018_6
 *	execIKK0081D022_6
 *	execIKK0081D024_4
 *	execIKK0081D028_4
 *	execIKK0081D036_7
 *	execIKK0081D063_4
 *	execIKK0081D064_4
 *	execIKK0081D065_4
 *	execIKK0271C001_1
 *	execIKK0271C001_3
 *	execIKK0271D001_1
 *	execIKK0271E001_1
 *	execIKK0271E001_6
 *	execIKK0281C001_2
 *	execIKK0281D001_2
 *	execIKK0291C001_2
 *	execIKK0291D001_2
 *	execIKK0841C002_8
 *
 */

public class JSYejbKK0271KRCK implements KanrenCheckHandler {

	/**
	 * コンストラクタ
	 */

	public JSYejbKK0271KRCK() {
	}

	/**
	 * 面開発案件関連チェックを行います。
	 * 
	 * @param inETMsg エンティティ
	 * @param inContext Agentから渡されたAgentDispatchContext
	 */

	public void invoke(CAANMsg inETMsg, AgentDispatchContext inContext) {

		JSYejbLog.println(JSYejbLog.DEBUG, getClass(), "call:JSYejbKK0271KRCK.invoke");

		// inETMsgのチェック
		if(inETMsg == null) {
			throw new CAANRuntimeException("inETMsgがnullです。");
		}

		// 振舞IDの取り出し
		String eventID = inETMsg.getString("eventID");
		if(eventID == null) {
			throw new CAANRuntimeException("振舞IDがnullです。");
		}

		// 処理の振り分け
		// イベントの振り分け
		if(eventID.equals(EventIDList.IKK0081D003)){
			/** サービス契約<eo光TV>登録振舞内部 */
			int Rtn = 0;
			Rtn = execIKK0081D003_7(inETMsg, inContext, "EA");

		}else if(eventID.equals(EventIDList.IKK0081D005)){
			/** サービス契約<eo光ネット>登録振舞内部 */
			int Rtn = 0;
			Rtn = execIKK0081D005_7(inETMsg, inContext, "EA");

		}else if(eventID.equals(EventIDList.IKK0081D008)){
			/** サービス契約<eo光電話>登録振舞内部 */
			int Rtn = 0;
			Rtn = execIKK0081D008_7(inETMsg, inContext, "EA");

		}else if(eventID.equals(EventIDList.IKK0081D013)){
			/** サービス契約<eo光TV>情報変更振舞内部 */
			int Rtn = 0;
			Rtn = execIKK0081D013_5(inETMsg, inContext, "EA");

		}else if(eventID.equals(EventIDList.IKK0081D017)){
			/** サービス契約<eoADSL>登録振舞内部 */
			int Rtn = 0;
			Rtn = execIKK0081D017_6(inETMsg, inContext, "EA");

		}else if(eventID.equals(EventIDList.IKK0081D018)){
			/** サービス契約<ホスティング>登録振舞内部 */
			int Rtn = 0;
			Rtn = execIKK0081D018_6(inETMsg, inContext, "EA");

		}else if(eventID.equals(EventIDList.IKK0081D022)){
			/** サービス契約<eoモバイル>登録振舞内部 */
			int Rtn = 0;
			Rtn = execIKK0081D022_6(inETMsg, inContext, "EA");

		}else if(eventID.equals(EventIDList.IKK0081D024)){
			/** サービス契約<eo光電話>情報変更振舞内部 */
			int Rtn = 0;
			Rtn = execIKK0081D024_4(inETMsg, inContext, "EA");

		}else if(eventID.equals(EventIDList.IKK0081D028)){
			/** サービス契約<eo光ネット>情報変更振舞内部 */
			int Rtn = 0;
			Rtn = execIKK0081D028_4(inETMsg, inContext, "EA");

		}else if(eventID.equals(EventIDList.IKK0081D036)){
			/** サービス契約<eoモバイル>情報変更振舞内部 */
			int Rtn = 0;
			Rtn = execIKK0081D036_7(inETMsg, inContext, "EA");

		}else if(eventID.equals(EventIDList.IKK0081D063)){
			/** サービス契約<eo光ネット>情報変更(住変)振舞内部 */
			int Rtn = 0;
			Rtn = execIKK0081D063_4(inETMsg, inContext, "EA");

		}else if(eventID.equals(EventIDList.IKK0081D064)){
			/** サービス契約<eo光TV>情報変更(住変)振舞内部 */
			int Rtn = 0;
			Rtn = execIKK0081D064_4(inETMsg, inContext, "EA");

		}else if(eventID.equals(EventIDList.IKK0081D065)){
			/** サービス契約<eo光電話>情報変更(住変)振舞内部 */
			int Rtn = 0;
			Rtn = execIKK0081D065_4(inETMsg, inContext, "EA");

		}else if(eventID.equals(EventIDList.IKK0271C001)){
			/** 面開発案件変更振舞内部 */
			int Rtn = 0;
			Rtn = execIKK0271C001_1(inETMsg, inContext, "EA");

			if(Rtn <= StatusCodes.WARNING){
				Rtn = execIKK0271C001_3(inETMsg, inContext, "EA");
			}

		}else if(eventID.equals(EventIDList.IKK0271D001)){
			/** 面開発案件登録振舞内部 */
			int Rtn = 0;
			Rtn = execIKK0271D001_1(inETMsg, inContext, "EA");

		}else if(eventID.equals(EventIDList.IKK0271E001)){
			/** 面開発案件削除振舞内部 */
			int Rtn = 0;
			Rtn = execIKK0271E001_1(inETMsg, inContext, "EA");

			if(Rtn <= StatusCodes.WARNING){
				Rtn = execIKK0271E001_6(inETMsg, inContext, "EA");
			}

		}else if(eventID.equals(EventIDList.IKK0281C001)){
			/** 面開発担当者変更振舞内部 */
			int Rtn = 0;
			Rtn = execIKK0281C001_2(inETMsg, inContext, "EB");

		}else if(eventID.equals(EventIDList.IKK0281D001)){
			/** 面開発担当者登録振舞内部 */
			int Rtn = 0;
			Rtn = execIKK0281D001_2(inETMsg, inContext, "EB");

		}else if(eventID.equals(EventIDList.IKK0291C001)){
			/** 面開発保証金変更振舞内部 */
			int Rtn = 0;
			Rtn = execIKK0291C001_2(inETMsg, inContext, "EB");

		}else if(eventID.equals(EventIDList.IKK0291D001)){
			/** 面開発保証金登録振舞内部 */
			int Rtn = 0;
			Rtn = execIKK0291D001_2(inETMsg, inContext, "EB");

		}else if(eventID.equals(EventIDList.IKK0841C002)){
			/** 割引サービス論理削除振舞内部 */
			int Rtn = 0;
			Rtn = execIKK0841C002_8(inETMsg, inContext, "EH");

		}

		JSYejbLog.println(JSYejbLog.DEBUG, getClass(), "end:JSYejbKK0271KRCK.invoke");

	}

	/**
	 * IKK0081D003_制約ＮＯ7チェック
	 *
	 * @param inETMsg チェック対象のETMsg(KK0081ETMsg)
	 * @param inContext Agentから渡されたAgentDispatchContext
	 * @param errFlag ERRフラグ
	 * @return int チェック結果
	 */
	private int execIKK0081D003_7(CAANMsg inETMsg, AgentDispatchContext inContext, String errFlag){

		// ステータス
		int rtn = 0;

		Connection con = JSYejbConnection.getConnection(KK0271ETMsg.getTableName());

		PreparedStatement pstmtQuery = null;
		ResultSet rsltQuery = null;
		StringBuffer sqlQuery = new StringBuffer();

		try{

			// チェック条件定数
			// ＳＱＬ引数定義
			String joken1_2 = null;
			if(!inETMsg.isNull(KK0081ETMsg.MENKAIHAT_ANKEN_NO)){
				joken1_2 = new String(inETMsg.getObject(KK0081ETMsg.MENKAIHAT_ANKEN_NO).toString());
			}

			String joken2_2 = "0";
			// 条件文定義
			String joken_1 = KK0271ETMsg.getDBColumnName(KK0271ETMsg.MENKAIHAT_ANKEN_NO);
			if(joken1_2 == null){
				joken_1 += " IS NULL ";
			}else{
				joken_1 += " = ? ";
			}

			String joken_2 = KK0271ETMsg.getDBColumnName(KK0271ETMsg.MK_FLG);
			if(joken2_2 == null){
				joken_2 += " IS NULL ";
			}else{
				joken_2 += " = ? ";
			}

			// チェック条件
			if (!inETMsg.isNull(KK0081ETMsg.MENKAIHAT_ANKEN_NO)) { 

				// ＳＱＬ文の組み立て
				sqlQuery.append("SELECT COUNT(*) CNT FROM ").append(KK0271ETMsg.getTableName()).append(" WHERE ")
					.append("(" + joken_1 + " AND " + joken_2 + " ) ");

				// ＳＱＬ文の解析
				pstmtQuery = con.prepareStatement(sqlQuery.toString());

				// パラメータの設定
				int para_idx = 1;
				if(joken1_2 != null){
					CAANJDBCUtil.setParam(pstmtQuery, para_idx++ , joken1_2);
				}
				if(joken2_2 != null){
					CAANJDBCUtil.setParam(pstmtQuery, para_idx++ , joken2_2);
				}

				// ＳＱＬ文の実行
				rsltQuery = pstmtQuery.executeQuery();

				if(rsltQuery.next()){
				// 判定条件
					if(!(rsltQuery.getLong("CNT")>0)){
						inETMsg.set(KK0081ETMsg.MENKAIHAT_ANKEN_NO_ERR, errFlag);
						if("W".equals(errFlag.substring(0,1))){
							rtn = StatusCodes.WARNING;
						} else {
							rtn = StatusCodes.RELATION_ERR;
						}
					}
				}

			}

		} catch(SQLException e) {
			inETMsg.set(KK0081ETMsg.STATUS, StatusCodes.FIND_DB_ERR);
			throw new CAANRuntimeException(e);
		} finally {
			// このメソッドで確保した資源の解放
			try {
				if(rsltQuery != null) {
					rsltQuery.close();
				}
				if(pstmtQuery != null) {
					pstmtQuery.close();
				}
				if(con != null) {
					CAANConnectionMgr.getInstance().close(con);
				}
			} catch(SQLException e) {
				inETMsg.set(KK0081ETMsg.STATUS, StatusCodes.FIND_DB_ERR);
				throw new CAANRuntimeException(e);
			}
		}
		
		// ステータスのセット
		if (rtn > inETMsg.getInt(KK0081ETMsg.STATUS)) {
			inETMsg.set(KK0081ETMsg.STATUS, rtn);
		}

		return rtn;

	}

	/**
	 * IKK0081D005_制約ＮＯ7チェック
	 *
	 * @param inETMsg チェック対象のETMsg(KK0081ETMsg)
	 * @param inContext Agentから渡されたAgentDispatchContext
	 * @param errFlag ERRフラグ
	 * @return int チェック結果
	 */
	private int execIKK0081D005_7(CAANMsg inETMsg, AgentDispatchContext inContext, String errFlag){

		// ステータス
		int rtn = 0;

		Connection con = JSYejbConnection.getConnection(KK0271ETMsg.getTableName());

		PreparedStatement pstmtQuery = null;
		ResultSet rsltQuery = null;
		StringBuffer sqlQuery = new StringBuffer();

		try{

			// チェック条件定数
			// ＳＱＬ引数定義
			String joken1_2 = null;
			if(!inETMsg.isNull(KK0081ETMsg.MENKAIHAT_ANKEN_NO)){
				joken1_2 = new String(inETMsg.getObject(KK0081ETMsg.MENKAIHAT_ANKEN_NO).toString());
			}

			String joken2_2 = "0";
			// 条件文定義
			String joken_1 = KK0271ETMsg.getDBColumnName(KK0271ETMsg.MENKAIHAT_ANKEN_NO);
			if(joken1_2 == null){
				joken_1 += " IS NULL ";
			}else{
				joken_1 += " = ? ";
			}

			String joken_2 = KK0271ETMsg.getDBColumnName(KK0271ETMsg.MK_FLG);
			if(joken2_2 == null){
				joken_2 += " IS NULL ";
			}else{
				joken_2 += " = ? ";
			}

			// チェック条件
			if (!inETMsg.isNull(KK0081ETMsg.MENKAIHAT_ANKEN_NO)) { 

				// ＳＱＬ文の組み立て
				sqlQuery.append("SELECT COUNT(*) CNT FROM ").append(KK0271ETMsg.getTableName()).append(" WHERE ")
					.append("(" + joken_1 + " AND " + joken_2 + " ) ");

				// ＳＱＬ文の解析
				pstmtQuery = con.prepareStatement(sqlQuery.toString());

				// パラメータの設定
				int para_idx = 1;
				if(joken1_2 != null){
					CAANJDBCUtil.setParam(pstmtQuery, para_idx++ , joken1_2);
				}
				if(joken2_2 != null){
					CAANJDBCUtil.setParam(pstmtQuery, para_idx++ , joken2_2);
				}

				// ＳＱＬ文の実行
				rsltQuery = pstmtQuery.executeQuery();

				if(rsltQuery.next()){
				// 判定条件
					if(!(rsltQuery.getLong("CNT")>0)){
						inETMsg.set(KK0081ETMsg.MENKAIHAT_ANKEN_NO_ERR, errFlag);
						if("W".equals(errFlag.substring(0,1))){
							rtn = StatusCodes.WARNING;
						} else {
							rtn = StatusCodes.RELATION_ERR;
						}
					}
				}

			}

		} catch(SQLException e) {
			inETMsg.set(KK0081ETMsg.STATUS, StatusCodes.FIND_DB_ERR);
			throw new CAANRuntimeException(e);
		} finally {
			// このメソッドで確保した資源の解放
			try {
				if(rsltQuery != null) {
					rsltQuery.close();
				}
				if(pstmtQuery != null) {
					pstmtQuery.close();
				}
				if(con != null) {
					CAANConnectionMgr.getInstance().close(con);
				}
			} catch(SQLException e) {
				inETMsg.set(KK0081ETMsg.STATUS, StatusCodes.FIND_DB_ERR);
				throw new CAANRuntimeException(e);
			}
		}
		
		// ステータスのセット
		if (rtn > inETMsg.getInt(KK0081ETMsg.STATUS)) {
			inETMsg.set(KK0081ETMsg.STATUS, rtn);
		}

		return rtn;

	}

	/**
	 * IKK0081D008_制約ＮＯ7チェック
	 *
	 * @param inETMsg チェック対象のETMsg(KK0081ETMsg)
	 * @param inContext Agentから渡されたAgentDispatchContext
	 * @param errFlag ERRフラグ
	 * @return int チェック結果
	 */
	private int execIKK0081D008_7(CAANMsg inETMsg, AgentDispatchContext inContext, String errFlag){

		// ステータス
		int rtn = 0;

		Connection con = JSYejbConnection.getConnection(KK0271ETMsg.getTableName());

		PreparedStatement pstmtQuery = null;
		ResultSet rsltQuery = null;
		StringBuffer sqlQuery = new StringBuffer();

		try{

			// チェック条件定数
			// ＳＱＬ引数定義
			String joken1_2 = null;
			if(!inETMsg.isNull(KK0081ETMsg.MENKAIHAT_ANKEN_NO)){
				joken1_2 = new String(inETMsg.getObject(KK0081ETMsg.MENKAIHAT_ANKEN_NO).toString());
			}

			String joken2_2 = "0";
			// 条件文定義
			String joken_1 = KK0271ETMsg.getDBColumnName(KK0271ETMsg.MENKAIHAT_ANKEN_NO);
			if(joken1_2 == null){
				joken_1 += " IS NULL ";
			}else{
				joken_1 += " = ? ";
			}

			String joken_2 = KK0271ETMsg.getDBColumnName(KK0271ETMsg.MK_FLG);
			if(joken2_2 == null){
				joken_2 += " IS NULL ";
			}else{
				joken_2 += " = ? ";
			}

			// チェック条件
			if (!inETMsg.isNull(KK0081ETMsg.MENKAIHAT_ANKEN_NO)) { 

				// ＳＱＬ文の組み立て
				sqlQuery.append("SELECT COUNT(*) CNT FROM ").append(KK0271ETMsg.getTableName()).append(" WHERE ")
					.append("(" + joken_1 + " AND " + joken_2 + " ) ");

				// ＳＱＬ文の解析
				pstmtQuery = con.prepareStatement(sqlQuery.toString());

				// パラメータの設定
				int para_idx = 1;
				if(joken1_2 != null){
					CAANJDBCUtil.setParam(pstmtQuery, para_idx++ , joken1_2);
				}
				if(joken2_2 != null){
					CAANJDBCUtil.setParam(pstmtQuery, para_idx++ , joken2_2);
				}

				// ＳＱＬ文の実行
				rsltQuery = pstmtQuery.executeQuery();

				if(rsltQuery.next()){
				// 判定条件
					if(!(rsltQuery.getLong("CNT")>0)){
						inETMsg.set(KK0081ETMsg.MENKAIHAT_ANKEN_NO_ERR, errFlag);
						if("W".equals(errFlag.substring(0,1))){
							rtn = StatusCodes.WARNING;
						} else {
							rtn = StatusCodes.RELATION_ERR;
						}
					}
				}

			}

		} catch(SQLException e) {
			inETMsg.set(KK0081ETMsg.STATUS, StatusCodes.FIND_DB_ERR);
			throw new CAANRuntimeException(e);
		} finally {
			// このメソッドで確保した資源の解放
			try {
				if(rsltQuery != null) {
					rsltQuery.close();
				}
				if(pstmtQuery != null) {
					pstmtQuery.close();
				}
				if(con != null) {
					CAANConnectionMgr.getInstance().close(con);
				}
			} catch(SQLException e) {
				inETMsg.set(KK0081ETMsg.STATUS, StatusCodes.FIND_DB_ERR);
				throw new CAANRuntimeException(e);
			}
		}
		
		// ステータスのセット
		if (rtn > inETMsg.getInt(KK0081ETMsg.STATUS)) {
			inETMsg.set(KK0081ETMsg.STATUS, rtn);
		}

		return rtn;

	}

	/**
	 * IKK0081D013_制約ＮＯ5チェック
	 *
	 * @param inETMsg チェック対象のETMsg(KK0081ETMsg)
	 * @param inContext Agentから渡されたAgentDispatchContext
	 * @param errFlag ERRフラグ
	 * @return int チェック結果
	 */
	private int execIKK0081D013_5(CAANMsg inETMsg, AgentDispatchContext inContext, String errFlag){

		// ステータス
		int rtn = 0;

		Connection con = JSYejbConnection.getConnection(KK0271ETMsg.getTableName());

		PreparedStatement pstmtQuery = null;
		ResultSet rsltQuery = null;
		StringBuffer sqlQuery = new StringBuffer();

		try{

			// チェック条件定数
			// ＳＱＬ引数定義
			String joken1_2 = null;
			if(!inETMsg.isNull(KK0081ETMsg.MENKAIHAT_ANKEN_NO)){
				joken1_2 = new String(inETMsg.getObject(KK0081ETMsg.MENKAIHAT_ANKEN_NO).toString());
			}

			String joken2_2 = "0";
			// 条件文定義
			String joken_1 = KK0271ETMsg.getDBColumnName(KK0271ETMsg.MENKAIHAT_ANKEN_NO);
			if(joken1_2 == null){
				joken_1 += " IS NULL ";
			}else{
				joken_1 += " = ? ";
			}

			String joken_2 = KK0271ETMsg.getDBColumnName(KK0271ETMsg.MK_FLG);
			if(joken2_2 == null){
				joken_2 += " IS NULL ";
			}else{
				joken_2 += " = ? ";
			}

			// チェック条件
			if (!inETMsg.isNull(KK0081ETMsg.MENKAIHAT_ANKEN_NO)) { 

				// ＳＱＬ文の組み立て
				sqlQuery.append("SELECT COUNT(*) CNT FROM ").append(KK0271ETMsg.getTableName()).append(" WHERE ")
					.append("(" + joken_1 + " AND " + joken_2 + " ) ");

				// ＳＱＬ文の解析
				pstmtQuery = con.prepareStatement(sqlQuery.toString());

				// パラメータの設定
				int para_idx = 1;
				if(joken1_2 != null){
					CAANJDBCUtil.setParam(pstmtQuery, para_idx++ , joken1_2);
				}
				if(joken2_2 != null){
					CAANJDBCUtil.setParam(pstmtQuery, para_idx++ , joken2_2);
				}

				// ＳＱＬ文の実行
				rsltQuery = pstmtQuery.executeQuery();

				if(rsltQuery.next()){
				// 判定条件
					if(!(rsltQuery.getLong("CNT")>0)){
						inETMsg.set(KK0081ETMsg.MENKAIHAT_ANKEN_NO_ERR, errFlag);
						if("W".equals(errFlag.substring(0,1))){
							rtn = StatusCodes.WARNING;
						} else {
							rtn = StatusCodes.RELATION_ERR;
						}
					}
				}

			}

		} catch(SQLException e) {
			inETMsg.set(KK0081ETMsg.STATUS, StatusCodes.FIND_DB_ERR);
			throw new CAANRuntimeException(e);
		} finally {
			// このメソッドで確保した資源の解放
			try {
				if(rsltQuery != null) {
					rsltQuery.close();
				}
				if(pstmtQuery != null) {
					pstmtQuery.close();
				}
				if(con != null) {
					CAANConnectionMgr.getInstance().close(con);
				}
			} catch(SQLException e) {
				inETMsg.set(KK0081ETMsg.STATUS, StatusCodes.FIND_DB_ERR);
				throw new CAANRuntimeException(e);
			}
		}
		
		// ステータスのセット
		if (rtn > inETMsg.getInt(KK0081ETMsg.STATUS)) {
			inETMsg.set(KK0081ETMsg.STATUS, rtn);
		}

		return rtn;

	}

	/**
	 * IKK0081D017_制約ＮＯ6チェック
	 *
	 * @param inETMsg チェック対象のETMsg(KK0081ETMsg)
	 * @param inContext Agentから渡されたAgentDispatchContext
	 * @param errFlag ERRフラグ
	 * @return int チェック結果
	 */
	private int execIKK0081D017_6(CAANMsg inETMsg, AgentDispatchContext inContext, String errFlag){

		// ステータス
		int rtn = 0;

		Connection con = JSYejbConnection.getConnection(KK0271ETMsg.getTableName());

		PreparedStatement pstmtQuery = null;
		ResultSet rsltQuery = null;
		StringBuffer sqlQuery = new StringBuffer();

		try{

			// チェック条件定数
			// ＳＱＬ引数定義
			String joken1_2 = null;
			if(!inETMsg.isNull(KK0081ETMsg.MENKAIHAT_ANKEN_NO)){
				joken1_2 = new String(inETMsg.getObject(KK0081ETMsg.MENKAIHAT_ANKEN_NO).toString());
			}

			String joken2_2 = "0";
			// 条件文定義
			String joken_1 = KK0271ETMsg.getDBColumnName(KK0271ETMsg.MENKAIHAT_ANKEN_NO);
			if(joken1_2 == null){
				joken_1 += " IS NULL ";
			}else{
				joken_1 += " = ? ";
			}

			String joken_2 = KK0271ETMsg.getDBColumnName(KK0271ETMsg.MK_FLG);
			if(joken2_2 == null){
				joken_2 += " IS NULL ";
			}else{
				joken_2 += " = ? ";
			}

			// チェック条件
			if (!inETMsg.isNull(KK0081ETMsg.MENKAIHAT_ANKEN_NO)) { 

				// ＳＱＬ文の組み立て
				sqlQuery.append("SELECT COUNT(*) CNT FROM ").append(KK0271ETMsg.getTableName()).append(" WHERE ")
					.append("(" + joken_1 + " AND " + joken_2 + " ) ");

				// ＳＱＬ文の解析
				pstmtQuery = con.prepareStatement(sqlQuery.toString());

				// パラメータの設定
				int para_idx = 1;
				if(joken1_2 != null){
					CAANJDBCUtil.setParam(pstmtQuery, para_idx++ , joken1_2);
				}
				if(joken2_2 != null){
					CAANJDBCUtil.setParam(pstmtQuery, para_idx++ , joken2_2);
				}

				// ＳＱＬ文の実行
				rsltQuery = pstmtQuery.executeQuery();

				if(rsltQuery.next()){
				// 判定条件
					if(!(rsltQuery.getLong("CNT")>0)){
						inETMsg.set(KK0081ETMsg.MENKAIHAT_ANKEN_NO_ERR, errFlag);
						if("W".equals(errFlag.substring(0,1))){
							rtn = StatusCodes.WARNING;
						} else {
							rtn = StatusCodes.RELATION_ERR;
						}
					}
				}

			}

		} catch(SQLException e) {
			inETMsg.set(KK0081ETMsg.STATUS, StatusCodes.FIND_DB_ERR);
			throw new CAANRuntimeException(e);
		} finally {
			// このメソッドで確保した資源の解放
			try {
				if(rsltQuery != null) {
					rsltQuery.close();
				}
				if(pstmtQuery != null) {
					pstmtQuery.close();
				}
				if(con != null) {
					CAANConnectionMgr.getInstance().close(con);
				}
			} catch(SQLException e) {
				inETMsg.set(KK0081ETMsg.STATUS, StatusCodes.FIND_DB_ERR);
				throw new CAANRuntimeException(e);
			}
		}
		
		// ステータスのセット
		if (rtn > inETMsg.getInt(KK0081ETMsg.STATUS)) {
			inETMsg.set(KK0081ETMsg.STATUS, rtn);
		}

		return rtn;

	}

	/**
	 * IKK0081D018_制約ＮＯ6チェック
	 *
	 * @param inETMsg チェック対象のETMsg(KK0081ETMsg)
	 * @param inContext Agentから渡されたAgentDispatchContext
	 * @param errFlag ERRフラグ
	 * @return int チェック結果
	 */
	private int execIKK0081D018_6(CAANMsg inETMsg, AgentDispatchContext inContext, String errFlag){

		// ステータス
		int rtn = 0;

		Connection con = JSYejbConnection.getConnection(KK0271ETMsg.getTableName());

		PreparedStatement pstmtQuery = null;
		ResultSet rsltQuery = null;
		StringBuffer sqlQuery = new StringBuffer();

		try{

			// チェック条件定数
			// ＳＱＬ引数定義
			String joken1_2 = null;
			if(!inETMsg.isNull(KK0081ETMsg.MENKAIHAT_ANKEN_NO)){
				joken1_2 = new String(inETMsg.getObject(KK0081ETMsg.MENKAIHAT_ANKEN_NO).toString());
			}

			String joken2_2 = "0";
			// 条件文定義
			String joken_1 = KK0271ETMsg.getDBColumnName(KK0271ETMsg.MENKAIHAT_ANKEN_NO);
			if(joken1_2 == null){
				joken_1 += " IS NULL ";
			}else{
				joken_1 += " = ? ";
			}

			String joken_2 = KK0271ETMsg.getDBColumnName(KK0271ETMsg.MK_FLG);
			if(joken2_2 == null){
				joken_2 += " IS NULL ";
			}else{
				joken_2 += " = ? ";
			}

			// チェック条件
			if (!inETMsg.isNull(KK0081ETMsg.MENKAIHAT_ANKEN_NO)) { 

				// ＳＱＬ文の組み立て
				sqlQuery.append("SELECT COUNT(*) CNT FROM ").append(KK0271ETMsg.getTableName()).append(" WHERE ")
					.append("(" + joken_1 + " AND " + joken_2 + " ) ");

				// ＳＱＬ文の解析
				pstmtQuery = con.prepareStatement(sqlQuery.toString());

				// パラメータの設定
				int para_idx = 1;
				if(joken1_2 != null){
					CAANJDBCUtil.setParam(pstmtQuery, para_idx++ , joken1_2);
				}
				if(joken2_2 != null){
					CAANJDBCUtil.setParam(pstmtQuery, para_idx++ , joken2_2);
				}

				// ＳＱＬ文の実行
				rsltQuery = pstmtQuery.executeQuery();

				if(rsltQuery.next()){
				// 判定条件
					if(!(rsltQuery.getLong("CNT")>0)){
						inETMsg.set(KK0081ETMsg.MENKAIHAT_ANKEN_NO_ERR, errFlag);
						if("W".equals(errFlag.substring(0,1))){
							rtn = StatusCodes.WARNING;
						} else {
							rtn = StatusCodes.RELATION_ERR;
						}
					}
				}

			}

		} catch(SQLException e) {
			inETMsg.set(KK0081ETMsg.STATUS, StatusCodes.FIND_DB_ERR);
			throw new CAANRuntimeException(e);
		} finally {
			// このメソッドで確保した資源の解放
			try {
				if(rsltQuery != null) {
					rsltQuery.close();
				}
				if(pstmtQuery != null) {
					pstmtQuery.close();
				}
				if(con != null) {
					CAANConnectionMgr.getInstance().close(con);
				}
			} catch(SQLException e) {
				inETMsg.set(KK0081ETMsg.STATUS, StatusCodes.FIND_DB_ERR);
				throw new CAANRuntimeException(e);
			}
		}
		
		// ステータスのセット
		if (rtn > inETMsg.getInt(KK0081ETMsg.STATUS)) {
			inETMsg.set(KK0081ETMsg.STATUS, rtn);
		}

		return rtn;

	}

	/**
	 * IKK0081D022_制約ＮＯ6チェック
	 *
	 * @param inETMsg チェック対象のETMsg(KK0081ETMsg)
	 * @param inContext Agentから渡されたAgentDispatchContext
	 * @param errFlag ERRフラグ
	 * @return int チェック結果
	 */
	private int execIKK0081D022_6(CAANMsg inETMsg, AgentDispatchContext inContext, String errFlag){

		// ステータス
		int rtn = 0;

		Connection con = JSYejbConnection.getConnection(KK0271ETMsg.getTableName());

		PreparedStatement pstmtQuery = null;
		ResultSet rsltQuery = null;
		StringBuffer sqlQuery = new StringBuffer();

		try{

			// チェック条件定数
			// ＳＱＬ引数定義
			String joken1_2 = null;
			if(!inETMsg.isNull(KK0081ETMsg.MENKAIHAT_ANKEN_NO)){
				joken1_2 = new String(inETMsg.getObject(KK0081ETMsg.MENKAIHAT_ANKEN_NO).toString());
			}

			String joken2_2 = "0";
			// 条件文定義
			String joken_1 = KK0271ETMsg.getDBColumnName(KK0271ETMsg.MENKAIHAT_ANKEN_NO);
			if(joken1_2 == null){
				joken_1 += " IS NULL ";
			}else{
				joken_1 += " = ? ";
			}

			String joken_2 = KK0271ETMsg.getDBColumnName(KK0271ETMsg.MK_FLG);
			if(joken2_2 == null){
				joken_2 += " IS NULL ";
			}else{
				joken_2 += " = ? ";
			}

			// チェック条件
			if (!inETMsg.isNull(KK0081ETMsg.MENKAIHAT_ANKEN_NO)) { 

				// ＳＱＬ文の組み立て
				sqlQuery.append("SELECT COUNT(*) CNT FROM ").append(KK0271ETMsg.getTableName()).append(" WHERE ")
					.append("(" + joken_1 + " AND " + joken_2 + " ) ");

				// ＳＱＬ文の解析
				pstmtQuery = con.prepareStatement(sqlQuery.toString());

				// パラメータの設定
				int para_idx = 1;
				if(joken1_2 != null){
					CAANJDBCUtil.setParam(pstmtQuery, para_idx++ , joken1_2);
				}
				if(joken2_2 != null){
					CAANJDBCUtil.setParam(pstmtQuery, para_idx++ , joken2_2);
				}

				// ＳＱＬ文の実行
				rsltQuery = pstmtQuery.executeQuery();

				if(rsltQuery.next()){
				// 判定条件
					if(!(rsltQuery.getLong("CNT")>0)){
						inETMsg.set(KK0081ETMsg.MENKAIHAT_ANKEN_NO_ERR, errFlag);
						if("W".equals(errFlag.substring(0,1))){
							rtn = StatusCodes.WARNING;
						} else {
							rtn = StatusCodes.RELATION_ERR;
						}
					}
				}

			}

		} catch(SQLException e) {
			inETMsg.set(KK0081ETMsg.STATUS, StatusCodes.FIND_DB_ERR);
			throw new CAANRuntimeException(e);
		} finally {
			// このメソッドで確保した資源の解放
			try {
				if(rsltQuery != null) {
					rsltQuery.close();
				}
				if(pstmtQuery != null) {
					pstmtQuery.close();
				}
				if(con != null) {
					CAANConnectionMgr.getInstance().close(con);
				}
			} catch(SQLException e) {
				inETMsg.set(KK0081ETMsg.STATUS, StatusCodes.FIND_DB_ERR);
				throw new CAANRuntimeException(e);
			}
		}
		
		// ステータスのセット
		if (rtn > inETMsg.getInt(KK0081ETMsg.STATUS)) {
			inETMsg.set(KK0081ETMsg.STATUS, rtn);
		}

		return rtn;

	}

	/**
	 * IKK0081D024_制約ＮＯ4チェック
	 *
	 * @param inETMsg チェック対象のETMsg(KK0081ETMsg)
	 * @param inContext Agentから渡されたAgentDispatchContext
	 * @param errFlag ERRフラグ
	 * @return int チェック結果
	 */
	private int execIKK0081D024_4(CAANMsg inETMsg, AgentDispatchContext inContext, String errFlag){

		// ステータス
		int rtn = 0;

		Connection con = JSYejbConnection.getConnection(KK0271ETMsg.getTableName());

		PreparedStatement pstmtQuery = null;
		ResultSet rsltQuery = null;
		StringBuffer sqlQuery = new StringBuffer();

		try{

			// チェック条件定数
			// ＳＱＬ引数定義
			String joken1_2 = null;
			if(!inETMsg.isNull(KK0081ETMsg.MENKAIHAT_ANKEN_NO)){
				joken1_2 = new String(inETMsg.getObject(KK0081ETMsg.MENKAIHAT_ANKEN_NO).toString());
			}

			String joken2_2 = "0";
			// 条件文定義
			String joken_1 = KK0271ETMsg.getDBColumnName(KK0271ETMsg.MENKAIHAT_ANKEN_NO);
			if(joken1_2 == null){
				joken_1 += " IS NULL ";
			}else{
				joken_1 += " = ? ";
			}

			String joken_2 = KK0271ETMsg.getDBColumnName(KK0271ETMsg.MK_FLG);
			if(joken2_2 == null){
				joken_2 += " IS NULL ";
			}else{
				joken_2 += " = ? ";
			}

			// チェック条件
			if (!inETMsg.isNull(KK0081ETMsg.MENKAIHAT_ANKEN_NO)) { 

				// ＳＱＬ文の組み立て
				sqlQuery.append("SELECT COUNT(*) CNT FROM ").append(KK0271ETMsg.getTableName()).append(" WHERE ")
					.append("(" + joken_1 + " AND " + joken_2 + " ) ");

				// ＳＱＬ文の解析
				pstmtQuery = con.prepareStatement(sqlQuery.toString());

				// パラメータの設定
				int para_idx = 1;
				if(joken1_2 != null){
					CAANJDBCUtil.setParam(pstmtQuery, para_idx++ , joken1_2);
				}
				if(joken2_2 != null){
					CAANJDBCUtil.setParam(pstmtQuery, para_idx++ , joken2_2);
				}

				// ＳＱＬ文の実行
				rsltQuery = pstmtQuery.executeQuery();

				if(rsltQuery.next()){
				// 判定条件
					if(!(rsltQuery.getLong("CNT")>0)){
						inETMsg.set(KK0081ETMsg.MENKAIHAT_ANKEN_NO_ERR, errFlag);
						if("W".equals(errFlag.substring(0,1))){
							rtn = StatusCodes.WARNING;
						} else {
							rtn = StatusCodes.RELATION_ERR;
						}
					}
				}

			}

		} catch(SQLException e) {
			inETMsg.set(KK0081ETMsg.STATUS, StatusCodes.FIND_DB_ERR);
			throw new CAANRuntimeException(e);
		} finally {
			// このメソッドで確保した資源の解放
			try {
				if(rsltQuery != null) {
					rsltQuery.close();
				}
				if(pstmtQuery != null) {
					pstmtQuery.close();
				}
				if(con != null) {
					CAANConnectionMgr.getInstance().close(con);
				}
			} catch(SQLException e) {
				inETMsg.set(KK0081ETMsg.STATUS, StatusCodes.FIND_DB_ERR);
				throw new CAANRuntimeException(e);
			}
		}
		
		// ステータスのセット
		if (rtn > inETMsg.getInt(KK0081ETMsg.STATUS)) {
			inETMsg.set(KK0081ETMsg.STATUS, rtn);
		}

		return rtn;

	}

	/**
	 * IKK0081D028_制約ＮＯ4チェック
	 *
	 * @param inETMsg チェック対象のETMsg(KK0081ETMsg)
	 * @param inContext Agentから渡されたAgentDispatchContext
	 * @param errFlag ERRフラグ
	 * @return int チェック結果
	 */
	private int execIKK0081D028_4(CAANMsg inETMsg, AgentDispatchContext inContext, String errFlag){

		// ステータス
		int rtn = 0;

		Connection con = JSYejbConnection.getConnection(KK0271ETMsg.getTableName());

		PreparedStatement pstmtQuery = null;
		ResultSet rsltQuery = null;
		StringBuffer sqlQuery = new StringBuffer();

		try{

			// チェック条件定数
			// ＳＱＬ引数定義
			String joken1_2 = null;
			if(!inETMsg.isNull(KK0081ETMsg.MENKAIHAT_ANKEN_NO)){
				joken1_2 = new String(inETMsg.getObject(KK0081ETMsg.MENKAIHAT_ANKEN_NO).toString());
			}

			String joken2_2 = "0";
			// 条件文定義
			String joken_1 = KK0271ETMsg.getDBColumnName(KK0271ETMsg.MENKAIHAT_ANKEN_NO);
			if(joken1_2 == null){
				joken_1 += " IS NULL ";
			}else{
				joken_1 += " = ? ";
			}

			String joken_2 = KK0271ETMsg.getDBColumnName(KK0271ETMsg.MK_FLG);
			if(joken2_2 == null){
				joken_2 += " IS NULL ";
			}else{
				joken_2 += " = ? ";
			}

			// チェック条件
			if (!inETMsg.isNull(KK0081ETMsg.MENKAIHAT_ANKEN_NO)) { 

				// ＳＱＬ文の組み立て
				sqlQuery.append("SELECT COUNT(*) CNT FROM ").append(KK0271ETMsg.getTableName()).append(" WHERE ")
					.append("(" + joken_1 + " AND " + joken_2 + " ) ");

				// ＳＱＬ文の解析
				pstmtQuery = con.prepareStatement(sqlQuery.toString());

				// パラメータの設定
				int para_idx = 1;
				if(joken1_2 != null){
					CAANJDBCUtil.setParam(pstmtQuery, para_idx++ , joken1_2);
				}
				if(joken2_2 != null){
					CAANJDBCUtil.setParam(pstmtQuery, para_idx++ , joken2_2);
				}

				// ＳＱＬ文の実行
				rsltQuery = pstmtQuery.executeQuery();

				if(rsltQuery.next()){
				// 判定条件
					if(!(rsltQuery.getLong("CNT")>0)){
						inETMsg.set(KK0081ETMsg.MENKAIHAT_ANKEN_NO_ERR, errFlag);
						if("W".equals(errFlag.substring(0,1))){
							rtn = StatusCodes.WARNING;
						} else {
							rtn = StatusCodes.RELATION_ERR;
						}
					}
				}

			}

		} catch(SQLException e) {
			inETMsg.set(KK0081ETMsg.STATUS, StatusCodes.FIND_DB_ERR);
			throw new CAANRuntimeException(e);
		} finally {
			// このメソッドで確保した資源の解放
			try {
				if(rsltQuery != null) {
					rsltQuery.close();
				}
				if(pstmtQuery != null) {
					pstmtQuery.close();
				}
				if(con != null) {
					CAANConnectionMgr.getInstance().close(con);
				}
			} catch(SQLException e) {
				inETMsg.set(KK0081ETMsg.STATUS, StatusCodes.FIND_DB_ERR);
				throw new CAANRuntimeException(e);
			}
		}
		
		// ステータスのセット
		if (rtn > inETMsg.getInt(KK0081ETMsg.STATUS)) {
			inETMsg.set(KK0081ETMsg.STATUS, rtn);
		}

		return rtn;

	}

	/**
	 * IKK0081D036_制約ＮＯ7チェック
	 *
	 * @param inETMsg チェック対象のETMsg(KK0081ETMsg)
	 * @param inContext Agentから渡されたAgentDispatchContext
	 * @param errFlag ERRフラグ
	 * @return int チェック結果
	 */
	private int execIKK0081D036_7(CAANMsg inETMsg, AgentDispatchContext inContext, String errFlag){

		// ステータス
		int rtn = 0;

		Connection con = JSYejbConnection.getConnection(KK0271ETMsg.getTableName());

		PreparedStatement pstmtQuery = null;
		ResultSet rsltQuery = null;
		StringBuffer sqlQuery = new StringBuffer();

		try{

			// チェック条件定数
			// ＳＱＬ引数定義
			String joken1_2 = null;
			if(!inETMsg.isNull(KK0081ETMsg.MENKAIHAT_ANKEN_NO)){
				joken1_2 = new String(inETMsg.getObject(KK0081ETMsg.MENKAIHAT_ANKEN_NO).toString());
			}

			String joken2_2 = "0";
			// 条件文定義
			String joken_1 = KK0271ETMsg.getDBColumnName(KK0271ETMsg.MENKAIHAT_ANKEN_NO);
			if(joken1_2 == null){
				joken_1 += " IS NULL ";
			}else{
				joken_1 += " = ? ";
			}

			String joken_2 = KK0271ETMsg.getDBColumnName(KK0271ETMsg.MK_FLG);
			if(joken2_2 == null){
				joken_2 += " IS NULL ";
			}else{
				joken_2 += " = ? ";
			}

			// チェック条件
			if (!inETMsg.isNull(KK0081ETMsg.MENKAIHAT_ANKEN_NO)) { 

				// ＳＱＬ文の組み立て
				sqlQuery.append("SELECT COUNT(*) CNT FROM ").append(KK0271ETMsg.getTableName()).append(" WHERE ")
					.append("(" + joken_1 + " AND " + joken_2 + " ) ");

				// ＳＱＬ文の解析
				pstmtQuery = con.prepareStatement(sqlQuery.toString());

				// パラメータの設定
				int para_idx = 1;
				if(joken1_2 != null){
					CAANJDBCUtil.setParam(pstmtQuery, para_idx++ , joken1_2);
				}
				if(joken2_2 != null){
					CAANJDBCUtil.setParam(pstmtQuery, para_idx++ , joken2_2);
				}

				// ＳＱＬ文の実行
				rsltQuery = pstmtQuery.executeQuery();

				if(rsltQuery.next()){
				// 判定条件
					if(!(rsltQuery.getLong("CNT")>0)){
						inETMsg.set(KK0081ETMsg.MENKAIHAT_ANKEN_NO_ERR, errFlag);
						if("W".equals(errFlag.substring(0,1))){
							rtn = StatusCodes.WARNING;
						} else {
							rtn = StatusCodes.RELATION_ERR;
						}
					}
				}

			}

		} catch(SQLException e) {
			inETMsg.set(KK0081ETMsg.STATUS, StatusCodes.FIND_DB_ERR);
			throw new CAANRuntimeException(e);
		} finally {
			// このメソッドで確保した資源の解放
			try {
				if(rsltQuery != null) {
					rsltQuery.close();
				}
				if(pstmtQuery != null) {
					pstmtQuery.close();
				}
				if(con != null) {
					CAANConnectionMgr.getInstance().close(con);
				}
			} catch(SQLException e) {
				inETMsg.set(KK0081ETMsg.STATUS, StatusCodes.FIND_DB_ERR);
				throw new CAANRuntimeException(e);
			}
		}
		
		// ステータスのセット
		if (rtn > inETMsg.getInt(KK0081ETMsg.STATUS)) {
			inETMsg.set(KK0081ETMsg.STATUS, rtn);
		}

		return rtn;

	}

	/**
	 * IKK0081D063_制約ＮＯ4チェック
	 *
	 * @param inETMsg チェック対象のETMsg(KK0081ETMsg)
	 * @param inContext Agentから渡されたAgentDispatchContext
	 * @param errFlag ERRフラグ
	 * @return int チェック結果
	 */
	private int execIKK0081D063_4(CAANMsg inETMsg, AgentDispatchContext inContext, String errFlag){

		// ステータス
		int rtn = 0;

		Connection con = JSYejbConnection.getConnection(KK0271ETMsg.getTableName());

		PreparedStatement pstmtQuery = null;
		ResultSet rsltQuery = null;
		StringBuffer sqlQuery = new StringBuffer();

		try{

			// チェック条件定数
			// ＳＱＬ引数定義
			String joken1_2 = null;
			if(!inETMsg.isNull(KK0081ETMsg.MENKAIHAT_ANKEN_NO)){
				joken1_2 = new String(inETMsg.getObject(KK0081ETMsg.MENKAIHAT_ANKEN_NO).toString());
			}

			String joken3_2 = "0";
			// 条件文定義
			String joken_1 = KK0271ETMsg.getDBColumnName(KK0271ETMsg.MENKAIHAT_ANKEN_NO);
			if(joken1_2 == null){
				joken_1 += " IS NULL ";
			}else{
				joken_1 += " = ? ";
			}

			String joken_3 = KK0271ETMsg.getDBColumnName(KK0271ETMsg.MK_FLG);
			if(joken3_2 == null){
				joken_3 += " IS NULL ";
			}else{
				joken_3 += " = ? ";
			}

			// チェック条件
			if (!inETMsg.isNull(KK0081ETMsg.MENKAIHAT_ANKEN_NO)) { 

				// ＳＱＬ文の組み立て
				sqlQuery.append("SELECT COUNT(*) CNT FROM ").append(KK0271ETMsg.getTableName()).append(" WHERE ")
					.append("(" + joken_1 + " AND " + joken_3 + " ) ");

				// ＳＱＬ文の解析
				pstmtQuery = con.prepareStatement(sqlQuery.toString());

				// パラメータの設定
				int para_idx = 1;
				if(joken1_2 != null){
					CAANJDBCUtil.setParam(pstmtQuery, para_idx++ , joken1_2);
				}
				if(joken3_2 != null){
					CAANJDBCUtil.setParam(pstmtQuery, para_idx++ , joken3_2);
				}

				// ＳＱＬ文の実行
				rsltQuery = pstmtQuery.executeQuery();

				if(rsltQuery.next()){
				// 判定条件
					if(!(rsltQuery.getLong("CNT")>0)){
						inETMsg.set(KK0081ETMsg.MENKAIHAT_ANKEN_NO_ERR, errFlag);
						if("W".equals(errFlag.substring(0,1))){
							rtn = StatusCodes.WARNING;
						} else {
							rtn = StatusCodes.RELATION_ERR;
						}
					}
				}

			}

		} catch(SQLException e) {
			inETMsg.set(KK0081ETMsg.STATUS, StatusCodes.FIND_DB_ERR);
			throw new CAANRuntimeException(e);
		} finally {
			// このメソッドで確保した資源の解放
			try {
				if(rsltQuery != null) {
					rsltQuery.close();
				}
				if(pstmtQuery != null) {
					pstmtQuery.close();
				}
				if(con != null) {
					CAANConnectionMgr.getInstance().close(con);
				}
			} catch(SQLException e) {
				inETMsg.set(KK0081ETMsg.STATUS, StatusCodes.FIND_DB_ERR);
				throw new CAANRuntimeException(e);
			}
		}
		
		// ステータスのセット
		if (rtn > inETMsg.getInt(KK0081ETMsg.STATUS)) {
			inETMsg.set(KK0081ETMsg.STATUS, rtn);
		}

		return rtn;

	}

	/**
	 * IKK0081D064_制約ＮＯ4チェック
	 *
	 * @param inETMsg チェック対象のETMsg(KK0081ETMsg)
	 * @param inContext Agentから渡されたAgentDispatchContext
	 * @param errFlag ERRフラグ
	 * @return int チェック結果
	 */
	private int execIKK0081D064_4(CAANMsg inETMsg, AgentDispatchContext inContext, String errFlag){

		// ステータス
		int rtn = 0;

		Connection con = JSYejbConnection.getConnection(KK0271ETMsg.getTableName());

		PreparedStatement pstmtQuery = null;
		ResultSet rsltQuery = null;
		StringBuffer sqlQuery = new StringBuffer();

		try{

			// チェック条件定数
			// ＳＱＬ引数定義
			String joken1_2 = null;
			if(!inETMsg.isNull(KK0081ETMsg.MENKAIHAT_ANKEN_NO)){
				joken1_2 = new String(inETMsg.getObject(KK0081ETMsg.MENKAIHAT_ANKEN_NO).toString());
			}

			String joken2_2 = "0";
			// 条件文定義
			String joken_1 = KK0271ETMsg.getDBColumnName(KK0271ETMsg.MENKAIHAT_ANKEN_NO);
			if(joken1_2 == null){
				joken_1 += " IS NULL ";
			}else{
				joken_1 += " = ? ";
			}

			String joken_2 = KK0271ETMsg.getDBColumnName(KK0271ETMsg.MK_FLG);
			if(joken2_2 == null){
				joken_2 += " IS NULL ";
			}else{
				joken_2 += " = ? ";
			}

			// チェック条件
			if (!inETMsg.isNull(KK0081ETMsg.MENKAIHAT_ANKEN_NO)) { 

				// ＳＱＬ文の組み立て
				sqlQuery.append("SELECT COUNT(*) CNT FROM ").append(KK0271ETMsg.getTableName()).append(" WHERE ")
					.append("(" + joken_1 + " AND " + joken_2 + " ) ");

				// ＳＱＬ文の解析
				pstmtQuery = con.prepareStatement(sqlQuery.toString());

				// パラメータの設定
				int para_idx = 1;
				if(joken1_2 != null){
					CAANJDBCUtil.setParam(pstmtQuery, para_idx++ , joken1_2);
				}
				if(joken2_2 != null){
					CAANJDBCUtil.setParam(pstmtQuery, para_idx++ , joken2_2);
				}

				// ＳＱＬ文の実行
				rsltQuery = pstmtQuery.executeQuery();

				if(rsltQuery.next()){
				// 判定条件
					if(!(rsltQuery.getLong("CNT")>0)){
						inETMsg.set(KK0081ETMsg.MENKAIHAT_ANKEN_NO_ERR, errFlag);
						if("W".equals(errFlag.substring(0,1))){
							rtn = StatusCodes.WARNING;
						} else {
							rtn = StatusCodes.RELATION_ERR;
						}
					}
				}

			}

		} catch(SQLException e) {
			inETMsg.set(KK0081ETMsg.STATUS, StatusCodes.FIND_DB_ERR);
			throw new CAANRuntimeException(e);
		} finally {
			// このメソッドで確保した資源の解放
			try {
				if(rsltQuery != null) {
					rsltQuery.close();
				}
				if(pstmtQuery != null) {
					pstmtQuery.close();
				}
				if(con != null) {
					CAANConnectionMgr.getInstance().close(con);
				}
			} catch(SQLException e) {
				inETMsg.set(KK0081ETMsg.STATUS, StatusCodes.FIND_DB_ERR);
				throw new CAANRuntimeException(e);
			}
		}
		
		// ステータスのセット
		if (rtn > inETMsg.getInt(KK0081ETMsg.STATUS)) {
			inETMsg.set(KK0081ETMsg.STATUS, rtn);
		}

		return rtn;

	}

	/**
	 * IKK0081D065_制約ＮＯ4チェック
	 *
	 * @param inETMsg チェック対象のETMsg(KK0081ETMsg)
	 * @param inContext Agentから渡されたAgentDispatchContext
	 * @param errFlag ERRフラグ
	 * @return int チェック結果
	 */
	private int execIKK0081D065_4(CAANMsg inETMsg, AgentDispatchContext inContext, String errFlag){

		// ステータス
		int rtn = 0;

		Connection con = JSYejbConnection.getConnection(KK0271ETMsg.getTableName());

		PreparedStatement pstmtQuery = null;
		ResultSet rsltQuery = null;
		StringBuffer sqlQuery = new StringBuffer();

		try{

			// チェック条件定数
			// ＳＱＬ引数定義
			String joken1_2 = null;
			if(!inETMsg.isNull(KK0081ETMsg.MENKAIHAT_ANKEN_NO)){
				joken1_2 = new String(inETMsg.getObject(KK0081ETMsg.MENKAIHAT_ANKEN_NO).toString());
			}

			String joken2_2 = "0";
			// 条件文定義
			String joken_1 = KK0271ETMsg.getDBColumnName(KK0271ETMsg.MENKAIHAT_ANKEN_NO);
			if(joken1_2 == null){
				joken_1 += " IS NULL ";
			}else{
				joken_1 += " = ? ";
			}

			String joken_2 = KK0271ETMsg.getDBColumnName(KK0271ETMsg.MK_FLG);
			if(joken2_2 == null){
				joken_2 += " IS NULL ";
			}else{
				joken_2 += " = ? ";
			}

			// チェック条件
			if (!inETMsg.isNull(KK0081ETMsg.MENKAIHAT_ANKEN_NO)) { 

				// ＳＱＬ文の組み立て
				sqlQuery.append("SELECT COUNT(*) CNT FROM ").append(KK0271ETMsg.getTableName()).append(" WHERE ")
					.append("(" + joken_1 + " AND " + joken_2 + " ) ");

				// ＳＱＬ文の解析
				pstmtQuery = con.prepareStatement(sqlQuery.toString());

				// パラメータの設定
				int para_idx = 1;
				if(joken1_2 != null){
					CAANJDBCUtil.setParam(pstmtQuery, para_idx++ , joken1_2);
				}
				if(joken2_2 != null){
					CAANJDBCUtil.setParam(pstmtQuery, para_idx++ , joken2_2);
				}

				// ＳＱＬ文の実行
				rsltQuery = pstmtQuery.executeQuery();

				if(rsltQuery.next()){
				// 判定条件
					if(!(rsltQuery.getLong("CNT")>0)){
						inETMsg.set(KK0081ETMsg.MENKAIHAT_ANKEN_NO_ERR, errFlag);
						if("W".equals(errFlag.substring(0,1))){
							rtn = StatusCodes.WARNING;
						} else {
							rtn = StatusCodes.RELATION_ERR;
						}
					}
				}

			}

		} catch(SQLException e) {
			inETMsg.set(KK0081ETMsg.STATUS, StatusCodes.FIND_DB_ERR);
			throw new CAANRuntimeException(e);
		} finally {
			// このメソッドで確保した資源の解放
			try {
				if(rsltQuery != null) {
					rsltQuery.close();
				}
				if(pstmtQuery != null) {
					pstmtQuery.close();
				}
				if(con != null) {
					CAANConnectionMgr.getInstance().close(con);
				}
			} catch(SQLException e) {
				inETMsg.set(KK0081ETMsg.STATUS, StatusCodes.FIND_DB_ERR);
				throw new CAANRuntimeException(e);
			}
		}
		
		// ステータスのセット
		if (rtn > inETMsg.getInt(KK0081ETMsg.STATUS)) {
			inETMsg.set(KK0081ETMsg.STATUS, rtn);
		}

		return rtn;

	}

	/**
	 * IKK0271C001_制約ＮＯ1チェック
	 *
	 * @param inETMsg チェック対象のETMsg(KK0271ETMsg)
	 * @param inContext Agentから渡されたAgentDispatchContext
	 * @param errFlag ERRフラグ
	 * @return int チェック結果
	 */
	private int execIKK0271C001_1(CAANMsg inETMsg, AgentDispatchContext inContext, String errFlag){

		// ステータス
		int rtn = 0;

		Connection con = JSYejbConnection.getConnection(KK0271ETMsg.getTableName());

		PreparedStatement pstmtQuery = null;
		ResultSet rsltQuery = null;
		StringBuffer sqlQuery = new StringBuffer();

		try{

			// チェック条件定数
			// ＳＱＬ引数定義
			String joken1_2 = null;
			if(!inETMsg.isNull(KK0271ETMsg.MENKAIHAT_ANKEN_NO)){
				joken1_2 = new String(inETMsg.getObject(KK0271ETMsg.MENKAIHAT_ANKEN_NO).toString());
			}

			String joken2_2 = "0";
			// 条件文定義
			String joken_1 = KK0271ETMsg.getDBColumnName(KK0271ETMsg.MENKAIHAT_ANKEN_NO);
			if(joken1_2 == null){
				joken_1 += " IS NULL ";
			}else{
				joken_1 += " = ? ";
			}

			String joken_2 = KK0271ETMsg.getDBColumnName(KK0271ETMsg.MK_FLG);
			if(joken2_2 == null){
				joken_2 += " IS NULL ";
			}else{
				joken_2 += " = ? ";
			}

			// チェック条件
			if (!inETMsg.isNull(KK0271ETMsg.MENKAIHAT_ANKEN_NO)) { 

				// ＳＱＬ文の組み立て
				sqlQuery.append("SELECT COUNT(*) CNT FROM ").append(KK0271ETMsg.getTableName()).append(" WHERE ")
					.append("(" + joken_1 + " AND " + joken_2 + " ) ");

				// ＳＱＬ文の解析
				pstmtQuery = con.prepareStatement(sqlQuery.toString());

				// パラメータの設定
				int para_idx = 1;
				if(joken1_2 != null){
					CAANJDBCUtil.setParam(pstmtQuery, para_idx++ , joken1_2);
				}
				if(joken2_2 != null){
					CAANJDBCUtil.setParam(pstmtQuery, para_idx++ , joken2_2);
				}

				// ＳＱＬ文の実行
				rsltQuery = pstmtQuery.executeQuery();

				if(rsltQuery.next()){
				// 判定条件
					if(!(rsltQuery.getLong("CNT")>0)){
						inETMsg.set(KK0271ETMsg.MENKAIHAT_ANKEN_NO_ERR, errFlag);
						if("W".equals(errFlag.substring(0,1))){
							rtn = StatusCodes.WARNING;
						} else {
							rtn = StatusCodes.RELATION_ERR;
						}
					}
				}

			}

		} catch(SQLException e) {
			inETMsg.set(KK0271ETMsg.STATUS, StatusCodes.FIND_DB_ERR);
			throw new CAANRuntimeException(e);
		} finally {
			// このメソッドで確保した資源の解放
			try {
				if(rsltQuery != null) {
					rsltQuery.close();
				}
				if(pstmtQuery != null) {
					pstmtQuery.close();
				}
				if(con != null) {
					CAANConnectionMgr.getInstance().close(con);
				}
			} catch(SQLException e) {
				inETMsg.set(KK0271ETMsg.STATUS, StatusCodes.FIND_DB_ERR);
				throw new CAANRuntimeException(e);
			}
		}
		
		// ステータスのセット
		if (rtn > inETMsg.getInt(KK0271ETMsg.STATUS)) {
			inETMsg.set(KK0271ETMsg.STATUS, rtn);
		}

		return rtn;

	}

	/**
	 * IKK0271C001_制約ＮＯ3チェック
	 *
	 * @param inETMsg チェック対象のETMsg(KK0271ETMsg)
	 * @param inContext Agentから渡されたAgentDispatchContext
	 * @param errFlag ERRフラグ
	 * @return int チェック結果
	 */
	private int execIKK0271C001_3(CAANMsg inETMsg, AgentDispatchContext inContext, String errFlag){

		// ステータス
		int rtn = 0;

			// チェック条件定数
			// 制約部品引数定義
			Object joken_1_prm_1 = "KK0271";

			// チェック条件
			if (!inETMsg.isNull(KK0271ETMsg.MENKAIHAT_ANKEN_NO) && !inETMsg.isNull(KK0271ETMsg.UPD_DTM)) { 
			// 判定条件
			if(JPCModelCommon.succeededExclusiveLock(inETMsg, inContext, joken_1_prm_1 ) == false){
					inETMsg.set(KK0271ETMsg.UPD_DTM_ERR, errFlag);
					if("W".equals(errFlag.substring(0,1))){
						rtn = StatusCodes.WARNING;
					} else {
						rtn = StatusCodes.RELATION_ERR;
					}
				}
			}

		
		// ステータスのセット
		if (rtn > inETMsg.getInt(KK0271ETMsg.STATUS)) {
			inETMsg.set(KK0271ETMsg.STATUS, rtn);
		}

		return rtn;

	}

	/**
	 * IKK0271D001_制約ＮＯ1チェック
	 *
	 * @param inETMsg チェック対象のETMsg(KK0271ETMsg)
	 * @param inContext Agentから渡されたAgentDispatchContext
	 * @param errFlag ERRフラグ
	 * @return int チェック結果
	 */
	private int execIKK0271D001_1(CAANMsg inETMsg, AgentDispatchContext inContext, String errFlag){

		// ステータス
		int rtn = 0;

		Connection con = JSYejbConnection.getConnection(KK0271ETMsg.getTableName());

		PreparedStatement pstmtQuery = null;
		ResultSet rsltQuery = null;
		StringBuffer sqlQuery = new StringBuffer();

		try{

			// チェック条件定数
			// ＳＱＬ引数定義
			String joken1_2 = null;
			if(!inETMsg.isNull(KK0271ETMsg.MENKAIHAT_ANKEN_NO)){
				joken1_2 = new String(inETMsg.getObject(KK0271ETMsg.MENKAIHAT_ANKEN_NO).toString());
			}

			// 条件文定義
			String joken_1 = KK0271ETMsg.getDBColumnName(KK0271ETMsg.MENKAIHAT_ANKEN_NO);
			if(joken1_2 == null){
				joken_1 += " IS NULL ";
			}else{
				joken_1 += " = ? ";
			}

			// チェック条件
			if (!inETMsg.isNull(KK0271ETMsg.MENKAIHAT_ANKEN_NO)) { 

				// ＳＱＬ文の組み立て
				sqlQuery.append("SELECT COUNT(*) CNT FROM ").append(KK0271ETMsg.getTableName()).append(" WHERE ")
					.append(joken_1);

				// ＳＱＬ文の解析
				pstmtQuery = con.prepareStatement(sqlQuery.toString());

				// パラメータの設定
				int para_idx = 1;
				if(joken1_2 != null){
					CAANJDBCUtil.setParam(pstmtQuery, para_idx++ , joken1_2);
				}

				// ＳＱＬ文の実行
				rsltQuery = pstmtQuery.executeQuery();

				if(rsltQuery.next()){
				// 判定条件
					if(rsltQuery.getLong("CNT")>0){
						inETMsg.set(KK0271ETMsg.MENKAIHAT_ANKEN_NO_ERR, errFlag);
						if("W".equals(errFlag.substring(0,1))){
							rtn = StatusCodes.WARNING;
						} else {
							rtn = StatusCodes.RELATION_ERR;
						}
					}
				}

			}

		} catch(SQLException e) {
			inETMsg.set(KK0271ETMsg.STATUS, StatusCodes.FIND_DB_ERR);
			throw new CAANRuntimeException(e);
		} finally {
			// このメソッドで確保した資源の解放
			try {
				if(rsltQuery != null) {
					rsltQuery.close();
				}
				if(pstmtQuery != null) {
					pstmtQuery.close();
				}
				if(con != null) {
					CAANConnectionMgr.getInstance().close(con);
				}
			} catch(SQLException e) {
				inETMsg.set(KK0271ETMsg.STATUS, StatusCodes.FIND_DB_ERR);
				throw new CAANRuntimeException(e);
			}
		}
		
		// ステータスのセット
		if (rtn > inETMsg.getInt(KK0271ETMsg.STATUS)) {
			inETMsg.set(KK0271ETMsg.STATUS, rtn);
		}

		return rtn;

	}

	/**
	 * IKK0271E001_制約ＮＯ1チェック
	 *
	 * @param inETMsg チェック対象のETMsg(KK0271ETMsg)
	 * @param inContext Agentから渡されたAgentDispatchContext
	 * @param errFlag ERRフラグ
	 * @return int チェック結果
	 */
	private int execIKK0271E001_1(CAANMsg inETMsg, AgentDispatchContext inContext, String errFlag){

		// ステータス
		int rtn = 0;

		Connection con = JSYejbConnection.getConnection(KK0271ETMsg.getTableName());

		PreparedStatement pstmtQuery = null;
		ResultSet rsltQuery = null;
		StringBuffer sqlQuery = new StringBuffer();

		try{

			// チェック条件定数
			// ＳＱＬ引数定義
			String joken1_2 = null;
			if(!inETMsg.isNull(KK0271ETMsg.MENKAIHAT_ANKEN_NO)){
				joken1_2 = new String(inETMsg.getObject(KK0271ETMsg.MENKAIHAT_ANKEN_NO).toString());
			}

			String joken2_2 = "0";
			// 条件文定義
			String joken_1 = KK0271ETMsg.getDBColumnName(KK0271ETMsg.MENKAIHAT_ANKEN_NO);
			if(joken1_2 == null){
				joken_1 += " IS NULL ";
			}else{
				joken_1 += " = ? ";
			}

			String joken_2 = KK0271ETMsg.getDBColumnName(KK0271ETMsg.MK_FLG);
			if(joken2_2 == null){
				joken_2 += " IS NULL ";
			}else{
				joken_2 += " = ? ";
			}

			// チェック条件
			if (!inETMsg.isNull(KK0271ETMsg.MENKAIHAT_ANKEN_NO)) { 

				// ＳＱＬ文の組み立て
				sqlQuery.append("SELECT COUNT(*) CNT FROM ").append(KK0271ETMsg.getTableName()).append(" WHERE ")
					.append("(" + joken_1 + " AND " + joken_2 + " ) ");

				// ＳＱＬ文の解析
				pstmtQuery = con.prepareStatement(sqlQuery.toString());

				// パラメータの設定
				int para_idx = 1;
				if(joken1_2 != null){
					CAANJDBCUtil.setParam(pstmtQuery, para_idx++ , joken1_2);
				}
				if(joken2_2 != null){
					CAANJDBCUtil.setParam(pstmtQuery, para_idx++ , joken2_2);
				}

				// ＳＱＬ文の実行
				rsltQuery = pstmtQuery.executeQuery();

				if(rsltQuery.next()){
				// 判定条件
					if(!(rsltQuery.getLong("CNT")>0)){
						inETMsg.set(KK0271ETMsg.MENKAIHAT_ANKEN_NO_ERR, errFlag);
						if("W".equals(errFlag.substring(0,1))){
							rtn = StatusCodes.WARNING;
						} else {
							rtn = StatusCodes.RELATION_ERR;
						}
					}
				}

			}

		} catch(SQLException e) {
			inETMsg.set(KK0271ETMsg.STATUS, StatusCodes.FIND_DB_ERR);
			throw new CAANRuntimeException(e);
		} finally {
			// このメソッドで確保した資源の解放
			try {
				if(rsltQuery != null) {
					rsltQuery.close();
				}
				if(pstmtQuery != null) {
					pstmtQuery.close();
				}
				if(con != null) {
					CAANConnectionMgr.getInstance().close(con);
				}
			} catch(SQLException e) {
				inETMsg.set(KK0271ETMsg.STATUS, StatusCodes.FIND_DB_ERR);
				throw new CAANRuntimeException(e);
			}
		}
		
		// ステータスのセット
		if (rtn > inETMsg.getInt(KK0271ETMsg.STATUS)) {
			inETMsg.set(KK0271ETMsg.STATUS, rtn);
		}

		return rtn;

	}

	/**
	 * IKK0271E001_制約ＮＯ6チェック
	 *
	 * @param inETMsg チェック対象のETMsg(KK0271ETMsg)
	 * @param inContext Agentから渡されたAgentDispatchContext
	 * @param errFlag ERRフラグ
	 * @return int チェック結果
	 */
	private int execIKK0271E001_6(CAANMsg inETMsg, AgentDispatchContext inContext, String errFlag){

		// ステータス
		int rtn = 0;

			// チェック条件定数
			// 制約部品引数定義
			Object joken_1_prm_1 = "KK0271";

			// チェック条件
			if (!inETMsg.isNull(KK0271ETMsg.MENKAIHAT_ANKEN_NO) && !inETMsg.isNull(KK0271ETMsg.UPD_DTM)) { 
			// 判定条件
			if(JPCModelCommon.succeededExclusiveLock(inETMsg, inContext, joken_1_prm_1 ) == false){
					inETMsg.set(KK0271ETMsg.UPD_DTM_ERR, errFlag);
					if("W".equals(errFlag.substring(0,1))){
						rtn = StatusCodes.WARNING;
					} else {
						rtn = StatusCodes.RELATION_ERR;
					}
				}
			}

		
		// ステータスのセット
		if (rtn > inETMsg.getInt(KK0271ETMsg.STATUS)) {
			inETMsg.set(KK0271ETMsg.STATUS, rtn);
		}

		return rtn;

	}

	/**
	 * IKK0281C001_制約ＮＯ2チェック
	 *
	 * @param inETMsg チェック対象のETMsg(KK0281ETMsg)
	 * @param inContext Agentから渡されたAgentDispatchContext
	 * @param errFlag ERRフラグ
	 * @return int チェック結果
	 */
	private int execIKK0281C001_2(CAANMsg inETMsg, AgentDispatchContext inContext, String errFlag){

		// ステータス
		int rtn = 0;

		Connection con = JSYejbConnection.getConnection(KK0271ETMsg.getTableName());

		PreparedStatement pstmtQuery = null;
		ResultSet rsltQuery = null;
		StringBuffer sqlQuery = new StringBuffer();

		try{

			// チェック条件定数
			// ＳＱＬ引数定義
			String joken1_2 = null;
			if(!inETMsg.isNull(KK0281ETMsg.MENKAIHAT_ANKEN_NO)){
				joken1_2 = new String(inETMsg.getObject(KK0281ETMsg.MENKAIHAT_ANKEN_NO).toString());
			}

			String joken2_2 = "0";
			// 条件文定義
			String joken_1 = KK0271ETMsg.getDBColumnName(KK0271ETMsg.MENKAIHAT_ANKEN_NO);
			if(joken1_2 == null){
				joken_1 += " IS NULL ";
			}else{
				joken_1 += " = ? ";
			}

			String joken_2 = KK0271ETMsg.getDBColumnName(KK0271ETMsg.MK_FLG);
			if(joken2_2 == null){
				joken_2 += " IS NULL ";
			}else{
				joken_2 += " = ? ";
			}

			// チェック条件
			if (!inETMsg.isNull(KK0281ETMsg.MENKAIHAT_ANKEN_NO)) { 

				// ＳＱＬ文の組み立て
				sqlQuery.append("SELECT COUNT(*) CNT FROM ").append(KK0271ETMsg.getTableName()).append(" WHERE ")
					.append("(" + joken_1 + " AND " + joken_2 + " ) ");

				// ＳＱＬ文の解析
				pstmtQuery = con.prepareStatement(sqlQuery.toString());

				// パラメータの設定
				int para_idx = 1;
				if(joken1_2 != null){
					CAANJDBCUtil.setParam(pstmtQuery, para_idx++ , joken1_2);
				}
				if(joken2_2 != null){
					CAANJDBCUtil.setParam(pstmtQuery, para_idx++ , joken2_2);
				}

				// ＳＱＬ文の実行
				rsltQuery = pstmtQuery.executeQuery();

				if(rsltQuery.next()){
				// 判定条件
					if(!(rsltQuery.getLong("CNT")>0)){
						inETMsg.set(KK0281ETMsg.MENKAIHAT_ANKEN_NO_ERR, errFlag);
						if("W".equals(errFlag.substring(0,1))){
							rtn = StatusCodes.WARNING;
						} else {
							rtn = StatusCodes.RELATION_ERR;
						}
					}
				}

			}

		} catch(SQLException e) {
			inETMsg.set(KK0281ETMsg.STATUS, StatusCodes.FIND_DB_ERR);
			throw new CAANRuntimeException(e);
		} finally {
			// このメソッドで確保した資源の解放
			try {
				if(rsltQuery != null) {
					rsltQuery.close();
				}
				if(pstmtQuery != null) {
					pstmtQuery.close();
				}
				if(con != null) {
					CAANConnectionMgr.getInstance().close(con);
				}
			} catch(SQLException e) {
				inETMsg.set(KK0281ETMsg.STATUS, StatusCodes.FIND_DB_ERR);
				throw new CAANRuntimeException(e);
			}
		}
		
		// ステータスのセット
		if (rtn > inETMsg.getInt(KK0281ETMsg.STATUS)) {
			inETMsg.set(KK0281ETMsg.STATUS, rtn);
		}

		return rtn;

	}

	/**
	 * IKK0281D001_制約ＮＯ2チェック
	 *
	 * @param inETMsg チェック対象のETMsg(KK0281ETMsg)
	 * @param inContext Agentから渡されたAgentDispatchContext
	 * @param errFlag ERRフラグ
	 * @return int チェック結果
	 */
	private int execIKK0281D001_2(CAANMsg inETMsg, AgentDispatchContext inContext, String errFlag){

		// ステータス
		int rtn = 0;

		Connection con = JSYejbConnection.getConnection(KK0271ETMsg.getTableName());

		PreparedStatement pstmtQuery = null;
		ResultSet rsltQuery = null;
		StringBuffer sqlQuery = new StringBuffer();

		try{

			// チェック条件定数
			// ＳＱＬ引数定義
			String joken1_2 = null;
			if(!inETMsg.isNull(KK0281ETMsg.MENKAIHAT_ANKEN_NO)){
				joken1_2 = new String(inETMsg.getObject(KK0281ETMsg.MENKAIHAT_ANKEN_NO).toString());
			}

			String joken2_2 = "0";
			// 条件文定義
			String joken_1 = KK0271ETMsg.getDBColumnName(KK0271ETMsg.MENKAIHAT_ANKEN_NO);
			if(joken1_2 == null){
				joken_1 += " IS NULL ";
			}else{
				joken_1 += " = ? ";
			}

			String joken_2 = KK0271ETMsg.getDBColumnName(KK0271ETMsg.MK_FLG);
			if(joken2_2 == null){
				joken_2 += " IS NULL ";
			}else{
				joken_2 += " = ? ";
			}

			// チェック条件
			if (!inETMsg.isNull(KK0281ETMsg.MENKAIHAT_ANKEN_NO)) { 

				// ＳＱＬ文の組み立て
				sqlQuery.append("SELECT COUNT(*) CNT FROM ").append(KK0271ETMsg.getTableName()).append(" WHERE ")
					.append("(" + joken_1 + " AND " + joken_2 + " ) ");

				// ＳＱＬ文の解析
				pstmtQuery = con.prepareStatement(sqlQuery.toString());

				// パラメータの設定
				int para_idx = 1;
				if(joken1_2 != null){
					CAANJDBCUtil.setParam(pstmtQuery, para_idx++ , joken1_2);
				}
				if(joken2_2 != null){
					CAANJDBCUtil.setParam(pstmtQuery, para_idx++ , joken2_2);
				}

				// ＳＱＬ文の実行
				rsltQuery = pstmtQuery.executeQuery();

				if(rsltQuery.next()){
				// 判定条件
					if(!(rsltQuery.getLong("CNT")>0)){
						inETMsg.set(KK0281ETMsg.MENKAIHAT_ANKEN_NO_ERR, errFlag);
						if("W".equals(errFlag.substring(0,1))){
							rtn = StatusCodes.WARNING;
						} else {
							rtn = StatusCodes.RELATION_ERR;
						}
					}
				}

			}

		} catch(SQLException e) {
			inETMsg.set(KK0281ETMsg.STATUS, StatusCodes.FIND_DB_ERR);
			throw new CAANRuntimeException(e);
		} finally {
			// このメソッドで確保した資源の解放
			try {
				if(rsltQuery != null) {
					rsltQuery.close();
				}
				if(pstmtQuery != null) {
					pstmtQuery.close();
				}
				if(con != null) {
					CAANConnectionMgr.getInstance().close(con);
				}
			} catch(SQLException e) {
				inETMsg.set(KK0281ETMsg.STATUS, StatusCodes.FIND_DB_ERR);
				throw new CAANRuntimeException(e);
			}
		}
		
		// ステータスのセット
		if (rtn > inETMsg.getInt(KK0281ETMsg.STATUS)) {
			inETMsg.set(KK0281ETMsg.STATUS, rtn);
		}

		return rtn;

	}

	/**
	 * IKK0291C001_制約ＮＯ2チェック
	 *
	 * @param inETMsg チェック対象のETMsg(KK0291ETMsg)
	 * @param inContext Agentから渡されたAgentDispatchContext
	 * @param errFlag ERRフラグ
	 * @return int チェック結果
	 */
	private int execIKK0291C001_2(CAANMsg inETMsg, AgentDispatchContext inContext, String errFlag){

		// ステータス
		int rtn = 0;

		Connection con = JSYejbConnection.getConnection(KK0271ETMsg.getTableName());

		PreparedStatement pstmtQuery = null;
		ResultSet rsltQuery = null;
		StringBuffer sqlQuery = new StringBuffer();

		try{

			// チェック条件定数
			// ＳＱＬ引数定義
			String joken1_2 = null;
			if(!inETMsg.isNull(KK0291ETMsg.MENKAIHAT_ANKEN_NO)){
				joken1_2 = new String(inETMsg.getObject(KK0291ETMsg.MENKAIHAT_ANKEN_NO).toString());
			}

			String joken2_2 = "0";
			// 条件文定義
			String joken_1 = KK0271ETMsg.getDBColumnName(KK0271ETMsg.MENKAIHAT_ANKEN_NO);
			if(joken1_2 == null){
				joken_1 += " IS NULL ";
			}else{
				joken_1 += " = ? ";
			}

			String joken_2 = KK0271ETMsg.getDBColumnName(KK0271ETMsg.MK_FLG);
			if(joken2_2 == null){
				joken_2 += " IS NULL ";
			}else{
				joken_2 += " = ? ";
			}

			// チェック条件
			if (!inETMsg.isNull(KK0291ETMsg.MENKAIHAT_ANKEN_NO)) { 

				// ＳＱＬ文の組み立て
				sqlQuery.append("SELECT COUNT(*) CNT FROM ").append(KK0271ETMsg.getTableName()).append(" WHERE ")
					.append("(" + joken_1 + " AND " + joken_2 + " ) ");

				// ＳＱＬ文の解析
				pstmtQuery = con.prepareStatement(sqlQuery.toString());

				// パラメータの設定
				int para_idx = 1;
				if(joken1_2 != null){
					CAANJDBCUtil.setParam(pstmtQuery, para_idx++ , joken1_2);
				}
				if(joken2_2 != null){
					CAANJDBCUtil.setParam(pstmtQuery, para_idx++ , joken2_2);
				}

				// ＳＱＬ文の実行
				rsltQuery = pstmtQuery.executeQuery();

				if(rsltQuery.next()){
				// 判定条件
					if(!(rsltQuery.getLong("CNT")>0)){
						inETMsg.set(KK0291ETMsg.MENKAIHAT_ANKEN_NO_ERR, errFlag);
						if("W".equals(errFlag.substring(0,1))){
							rtn = StatusCodes.WARNING;
						} else {
							rtn = StatusCodes.RELATION_ERR;
						}
					}
				}

			}

		} catch(SQLException e) {
			inETMsg.set(KK0291ETMsg.STATUS, StatusCodes.FIND_DB_ERR);
			throw new CAANRuntimeException(e);
		} finally {
			// このメソッドで確保した資源の解放
			try {
				if(rsltQuery != null) {
					rsltQuery.close();
				}
				if(pstmtQuery != null) {
					pstmtQuery.close();
				}
				if(con != null) {
					CAANConnectionMgr.getInstance().close(con);
				}
			} catch(SQLException e) {
				inETMsg.set(KK0291ETMsg.STATUS, StatusCodes.FIND_DB_ERR);
				throw new CAANRuntimeException(e);
			}
		}
		
		// ステータスのセット
		if (rtn > inETMsg.getInt(KK0291ETMsg.STATUS)) {
			inETMsg.set(KK0291ETMsg.STATUS, rtn);
		}

		return rtn;

	}

	/**
	 * IKK0291D001_制約ＮＯ2チェック
	 *
	 * @param inETMsg チェック対象のETMsg(KK0291ETMsg)
	 * @param inContext Agentから渡されたAgentDispatchContext
	 * @param errFlag ERRフラグ
	 * @return int チェック結果
	 */
	private int execIKK0291D001_2(CAANMsg inETMsg, AgentDispatchContext inContext, String errFlag){

		// ステータス
		int rtn = 0;

		Connection con = JSYejbConnection.getConnection(KK0271ETMsg.getTableName());

		PreparedStatement pstmtQuery = null;
		ResultSet rsltQuery = null;
		StringBuffer sqlQuery = new StringBuffer();

		try{

			// チェック条件定数
			// ＳＱＬ引数定義
			String joken1_2 = null;
			if(!inETMsg.isNull(KK0291ETMsg.MENKAIHAT_ANKEN_NO)){
				joken1_2 = new String(inETMsg.getObject(KK0291ETMsg.MENKAIHAT_ANKEN_NO).toString());
			}

			String joken2_2 = "0";
			// 条件文定義
			String joken_1 = KK0271ETMsg.getDBColumnName(KK0271ETMsg.MENKAIHAT_ANKEN_NO);
			if(joken1_2 == null){
				joken_1 += " IS NULL ";
			}else{
				joken_1 += " = ? ";
			}

			String joken_2 = KK0271ETMsg.getDBColumnName(KK0271ETMsg.MK_FLG);
			if(joken2_2 == null){
				joken_2 += " IS NULL ";
			}else{
				joken_2 += " = ? ";
			}

			// チェック条件
			if (!inETMsg.isNull(KK0291ETMsg.MENKAIHAT_ANKEN_NO)) { 

				// ＳＱＬ文の組み立て
				sqlQuery.append("SELECT COUNT(*) CNT FROM ").append(KK0271ETMsg.getTableName()).append(" WHERE ")
					.append("(" + joken_1 + " AND " + joken_2 + " ) ");

				// ＳＱＬ文の解析
				pstmtQuery = con.prepareStatement(sqlQuery.toString());

				// パラメータの設定
				int para_idx = 1;
				if(joken1_2 != null){
					CAANJDBCUtil.setParam(pstmtQuery, para_idx++ , joken1_2);
				}
				if(joken2_2 != null){
					CAANJDBCUtil.setParam(pstmtQuery, para_idx++ , joken2_2);
				}

				// ＳＱＬ文の実行
				rsltQuery = pstmtQuery.executeQuery();

				if(rsltQuery.next()){
				// 判定条件
					if(!(rsltQuery.getLong("CNT")>0)){
						inETMsg.set(KK0291ETMsg.MENKAIHAT_ANKEN_NO_ERR, errFlag);
						if("W".equals(errFlag.substring(0,1))){
							rtn = StatusCodes.WARNING;
						} else {
							rtn = StatusCodes.RELATION_ERR;
						}
					}
				}

			}

		} catch(SQLException e) {
			inETMsg.set(KK0291ETMsg.STATUS, StatusCodes.FIND_DB_ERR);
			throw new CAANRuntimeException(e);
		} finally {
			// このメソッドで確保した資源の解放
			try {
				if(rsltQuery != null) {
					rsltQuery.close();
				}
				if(pstmtQuery != null) {
					pstmtQuery.close();
				}
				if(con != null) {
					CAANConnectionMgr.getInstance().close(con);
				}
			} catch(SQLException e) {
				inETMsg.set(KK0291ETMsg.STATUS, StatusCodes.FIND_DB_ERR);
				throw new CAANRuntimeException(e);
			}
		}
		
		// ステータスのセット
		if (rtn > inETMsg.getInt(KK0291ETMsg.STATUS)) {
			inETMsg.set(KK0291ETMsg.STATUS, rtn);
		}

		return rtn;

	}

	/**
	 * IKK0841C002_制約ＮＯ8チェック
	 *
	 * @param inETMsg チェック対象のETMsg(KK0841ETMsg)
	 * @param inContext Agentから渡されたAgentDispatchContext
	 * @param errFlag ERRフラグ
	 * @return int チェック結果
	 */
	private int execIKK0841C002_8(CAANMsg inETMsg, AgentDispatchContext inContext, String errFlag){

		// ステータス
		int rtn = 0;

		Connection con = JSYejbConnection.getConnection(KK0271ETMsg.getTableName());

		PreparedStatement pstmtQuery = null;
		ResultSet rsltQuery = null;
		StringBuffer sqlQuery = new StringBuffer();

		try{

			// チェック条件定数
			// ＳＱＬ引数定義
			String joken1_2 = null;
			if(!inETMsg.isNull(KK0841ETMsg.WRIB_SVC_CD)){
				joken1_2 = new String(inETMsg.getObject(KK0841ETMsg.WRIB_SVC_CD).toString());
			}

			String joken2_2 = "0";
			// 条件文定義
			String joken_1 = KK0271ETMsg.getDBColumnName(KK0271ETMsg.WRIB_SVC_CD);
			if(joken1_2 == null){
				joken_1 += " IS NULL ";
			}else{
				joken_1 += " = ? ";
			}

			String joken_2 = KK0271ETMsg.getDBColumnName(KK0271ETMsg.MK_FLG);
			if(joken2_2 == null){
				joken_2 += " IS NULL ";
			}else{
				joken_2 += " = ? ";
			}

			// チェック条件
			if (!inETMsg.isNull(KK0841ETMsg.WRIB_SVC_CD)) { 

				// ＳＱＬ文の組み立て
				sqlQuery.append("SELECT COUNT(*) CNT FROM ").append(KK0271ETMsg.getTableName()).append(" WHERE ")
					.append("(" + joken_1 + " AND " + joken_2 + " ) ");

				// ＳＱＬ文の解析
				pstmtQuery = con.prepareStatement(sqlQuery.toString());

				// パラメータの設定
				int para_idx = 1;
				if(joken1_2 != null){
					CAANJDBCUtil.setParam(pstmtQuery, para_idx++ , joken1_2);
				}
				if(joken2_2 != null){
					CAANJDBCUtil.setParam(pstmtQuery, para_idx++ , joken2_2);
				}

				// ＳＱＬ文の実行
				rsltQuery = pstmtQuery.executeQuery();

				if(rsltQuery.next()){
				// 判定条件
					if(rsltQuery.getLong("CNT")>0){
						inETMsg.set(KK0841ETMsg.WRIB_SVC_CD_ERR, errFlag);
						if("W".equals(errFlag.substring(0,1))){
							rtn = StatusCodes.WARNING;
						} else {
							rtn = StatusCodes.RELATION_ERR;
						}
					}
				}

			}

		} catch(SQLException e) {
			inETMsg.set(KK0841ETMsg.STATUS, StatusCodes.FIND_DB_ERR);
			throw new CAANRuntimeException(e);
		} finally {
			// このメソッドで確保した資源の解放
			try {
				if(rsltQuery != null) {
					rsltQuery.close();
				}
				if(pstmtQuery != null) {
					pstmtQuery.close();
				}
				if(con != null) {
					CAANConnectionMgr.getInstance().close(con);
				}
			} catch(SQLException e) {
				inETMsg.set(KK0841ETMsg.STATUS, StatusCodes.FIND_DB_ERR);
				throw new CAANRuntimeException(e);
			}
		}
		
		// ステータスのセット
		if (rtn > inETMsg.getInt(KK0841ETMsg.STATUS)) {
			inETMsg.set(KK0841ETMsg.STATUS, rtn);
		}

		return rtn;

	}

}

