/*******************************************************************************
*	 All Rights reserved,Copyright (c) K-Opticom 
********************************************************************************
*＜プログラム内容＞
*	システム名		：eo顧客基幹システム
*	モジュール名	：JSYejbKK0251KRCK
*	ソースファイル名：JSYejbKK0251KRCK.java
*	作成者			：EK945604
*	日付			：2018年01月17日
*＜機能概要＞
*	関連チェック部品です。
*＜修正履歴＞
*	バージョン	修正日		修正者		修正内容
*	ｖ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.JKKModelCommon;

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
 *	execIKK0241D003_3
 *	execIKK0251C001_1
 *	execIKK0251D002_1
 *	execIKK0251D002_2
 *	execIKK0251D002_5
 *	execIKK0251D005_1
 *	execIKK0251D005_2
 *	execIKK0251D005_7
 *	execIKK0251D006_1
 *	execIKK0251D006_2
 *	execIKK0251D007_1
 *	execIKK0251D007_2
 *	execIKK0251D008_1
 *	execIKK0251D008_2
 *	execIKK0251D009_1
 *	execIKK0251D009_2
 *	execIKK0251D010_1
 *	execIKK0251D010_2
 *	execIKK0251D010_5
 *	execIKK0341C020_2
 *	execIKK0341D002_8
 *	execIKK0341D021_3
 *	execIKK1041D001_8
 *	execIKK1081D001_9
 *	execIKK1091D001_8
 *	execIKK2961D001_3
 *	execIKK3011D001_2
 *	execIKK3131D001_2
 *
 */

public class JSYejbKK0251KRCK implements KanrenCheckHandler {

	/**
	 * コンストラクタ
	 */

	public JSYejbKK0251KRCK() {
	}

	/**
	 * サービス契約回線内訳関連チェックを行います。
	 * 
	 * @param inETMsg エンティティ
	 * @param inContext Agentから渡されたAgentDispatchContext
	 */

	public void invoke(CAANMsg inETMsg, AgentDispatchContext inContext) {

		JSYejbLog.println(JSYejbLog.DEBUG, getClass(), "call:JSYejbKK0251KRCK.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.IKK0241D003)){
			/** 回線対象サービス契約登録振舞内部 */
			int Rtn = 0;
			Rtn = execIKK0241D003_3(inETMsg, inContext, "EA");

		}else if(eventID.equals(EventIDList.IKK0251C001)){
			/** サービス契約回線内訳申込情報変更振舞内部 */
			int Rtn = 0;
			Rtn = execIKK0251C001_1(inETMsg, inContext, "EA");

		}else if(eventID.equals(EventIDList.IKK0251D002)){
			/** サービス契約回線内訳登録振舞内部 */
			int Rtn = 0;
			Rtn = execIKK0251D002_1(inETMsg, inContext, "EA");

			if(Rtn <= StatusCodes.WARNING){
				Rtn = execIKK0251D002_2(inETMsg, inContext, "EB");
			}

			if(Rtn <= StatusCodes.WARNING){
				Rtn = execIKK0251D002_5(inETMsg, inContext, "WA");
			}

		}else if(eventID.equals(EventIDList.IKK0251D005)){
			/** サービス契約回線内訳内容変更振舞内部 */
			int Rtn = 0;
			Rtn = execIKK0251D005_1(inETMsg, inContext, "EA");

			if(Rtn <= StatusCodes.WARNING){
				Rtn = execIKK0251D005_2(inETMsg, inContext, "EB");
			}

			if(Rtn <= StatusCodes.WARNING){
				Rtn = execIKK0251D005_7(inETMsg, inContext, "WA");
			}

		}else if(eventID.equals(EventIDList.IKK0251D006)){
			/** サービス契約回線内訳キャンセル振舞内部 */
			int Rtn = 0;
			Rtn = execIKK0251D006_1(inETMsg, inContext, "EA");

			if(Rtn <= StatusCodes.WARNING){
				Rtn = execIKK0251D006_2(inETMsg, inContext, "EB");
			}

		}else if(eventID.equals(EventIDList.IKK0251D007)){
			/** サービス契約回線内訳使用停止振舞内部 */
			int Rtn = 0;
			Rtn = execIKK0251D007_1(inETMsg, inContext, "EA");

			if(Rtn <= StatusCodes.WARNING){
				Rtn = execIKK0251D007_2(inETMsg, inContext, "EB");
			}

		}else if(eventID.equals(EventIDList.IKK0251D008)){
			/** サービス契約回線内訳キャンセル取消振舞内部 */
			int Rtn = 0;
			Rtn = execIKK0251D008_1(inETMsg, inContext, "EA");

			if(Rtn <= StatusCodes.WARNING){
				Rtn = execIKK0251D008_2(inETMsg, inContext, "EB");
			}

		}else if(eventID.equals(EventIDList.IKK0251D009)){
			/** サービス契約回線内訳使用再開振舞内部 */
			int Rtn = 0;
			Rtn = execIKK0251D009_1(inETMsg, inContext, "EA");

			if(Rtn <= StatusCodes.WARNING){
				Rtn = execIKK0251D009_2(inETMsg, inContext, "EB");
			}

		}else if(eventID.equals(EventIDList.IKK0251D010)){
			/** サービス契約回線内訳登録（住所変更）振舞内部 */
			int Rtn = 0;
			Rtn = execIKK0251D010_1(inETMsg, inContext, "EA");

			if(Rtn <= StatusCodes.WARNING){
				Rtn = execIKK0251D010_2(inETMsg, inContext, "EB");
			}

			if(Rtn <= StatusCodes.WARNING){
				Rtn = execIKK0251D010_5(inETMsg, inContext, "WA");
			}

		}else if(eventID.equals(EventIDList.IKK0341C020)){
			/** 機器提供サービス契約回線内訳変更(変更中)振舞内部 */
			int Rtn = 0;
			Rtn = execIKK0341C020_2(inETMsg, inContext, "EA");

		}else if(eventID.equals(EventIDList.IKK0341D002)){
			/** 機器提供サービス契約登録振舞内部 */
			int Rtn = 0;
			Rtn = execIKK0341D002_8(inETMsg, inContext, "EA");

		}else if(eventID.equals(EventIDList.IKK0341D021)){
			/** 機器提供サービス契約サービス契約回線内訳変更 */
			int Rtn = 0;
			Rtn = execIKK0341D021_3(inETMsg, inContext, "EA");

		}else if(eventID.equals(EventIDList.IKK1041D001)){
			/** オーダ設定登録振舞内部 */
			int Rtn = 0;
			Rtn = execIKK1041D001_8(inETMsg, inContext, "EA");

		}else if(eventID.equals(EventIDList.IKK1081D001)){
			/** オーダ発行条件登録振舞内部 */
			int Rtn = 0;
			Rtn = execIKK1081D001_9(inETMsg, inContext, "EA");

		}else if(eventID.equals(EventIDList.IKK1091D001)){
			/** 進捗登録振舞内部 */
			int Rtn = 0;
			Rtn = execIKK1091D001_8(inETMsg, inContext, "EA");

		}else if(eventID.equals(EventIDList.IKK2961D001)){
			/** サービス契約グループ設定登録振舞内部 */
			int Rtn = 0;
			Rtn = execIKK2961D001_3(inETMsg, inContext, "EA");

		}else if(eventID.equals(EventIDList.IKK3011D001)){
			/** 契約内容通知書登録振舞内部 */
			int Rtn = 0;
			Rtn = execIKK3011D001_2(inETMsg, inContext, "EA");

		}else if(eventID.equals(EventIDList.IKK3131D001)){
			/** 工事費割賦契約登録振舞内部 */
			int Rtn = 0;
			Rtn = execIKK3131D001_2(inETMsg, inContext, "EA");

		}

		JSYejbLog.println(JSYejbLog.DEBUG, getClass(), "end:JSYejbKK0251KRCK.invoke");

	}

	/**
	 * IKK0241D003_制約ＮＯ3チェック
	 *
	 * @param inETMsg チェック対象のETMsg(KK0241ETMsg)
	 * @param inContext Agentから渡されたAgentDispatchContext
	 * @param errFlag ERRフラグ
	 * @return int チェック結果
	 */
	private int execIKK0241D003_3(CAANMsg inETMsg, AgentDispatchContext inContext, String errFlag){

		// ステータス
		int rtn = 0;

		Connection con = JSYejbConnection.getConnection(KK0251ETMsg.getTableName());

		PreparedStatement pstmtQuery = null;
		ResultSet rsltQuery = null;
		StringBuffer sqlQuery = new StringBuffer();

		try{

			// チェック条件定数
			// ＳＱＬ引数定義
			String joken1_2 = null;
			if(!inETMsg.isNull(KK0241ETMsg.SVC_KEI_KAISEN_UCWK_NO)){
				joken1_2 = new String(inETMsg.getObject(KK0241ETMsg.SVC_KEI_KAISEN_UCWK_NO).toString());
			}

			String joken2_2 = "0";
			// 条件文定義
			String joken_1 = KK0251ETMsg.getDBColumnName(KK0251ETMsg.SVC_KEI_KAISEN_UCWK_NO);
			if(joken1_2 == null){
				joken_1 += " IS NULL ";
			}else{
				joken_1 += " = ? ";
			}

			String joken_2 = KK0251ETMsg.getDBColumnName(KK0251ETMsg.MK_FLG);
			if(joken2_2 == null){
				joken_2 += " IS NULL ";
			}else{
				joken_2 += " = ? ";
			}

			// チェック条件
			if (!inETMsg.isNull(KK0241ETMsg.SVC_KEI_KAISEN_UCWK_NO)) { 

				// ＳＱＬ文の組み立て
				sqlQuery.append("SELECT COUNT(*) CNT FROM ").append(KK0251ETMsg.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(KK0241ETMsg.SVC_KEI_KAISEN_UCWK_NO_ERR, errFlag);
						if("W".equals(errFlag.substring(0,1))){
							rtn = StatusCodes.WARNING;
						} else {
							rtn = StatusCodes.RELATION_ERR;
						}
					}
				}

			}

		} catch(SQLException e) {
			inETMsg.set(KK0241ETMsg.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(KK0241ETMsg.STATUS, StatusCodes.FIND_DB_ERR);
				throw new CAANRuntimeException(e);
			}
		}
		
		// ステータスのセット
		if (rtn > inETMsg.getInt(KK0241ETMsg.STATUS)) {
			inETMsg.set(KK0241ETMsg.STATUS, rtn);
		}

		return rtn;

	}

	/**
	 * IKK0251C001_制約ＮＯ1チェック
	 *
	 * @param inETMsg チェック対象のETMsg(KK0251ETMsg)
	 * @param inContext Agentから渡されたAgentDispatchContext
	 * @param errFlag ERRフラグ
	 * @return int チェック結果
	 */
	private int execIKK0251C001_1(CAANMsg inETMsg, AgentDispatchContext inContext, String errFlag){

		// ステータス
		int rtn = 0;

		Connection con = JSYejbConnection.getConnection(KK0251ETMsg.getTableName());

		PreparedStatement pstmtQuery = null;
		ResultSet rsltQuery = null;
		StringBuffer sqlQuery = new StringBuffer();

		try{

			// チェック条件定数
			// ＳＱＬ引数定義
			String joken1_2 = null;
			if(!inETMsg.isNull(KK0251ETMsg.SVC_KEI_KAISEN_UCWK_NO)){
				joken1_2 = new String(inETMsg.getObject(KK0251ETMsg.SVC_KEI_KAISEN_UCWK_NO).toString());
			}

			String joken2_2 = null;
			if(!inETMsg.isNull(KK0251ETMsg.GENE_ADD_DTM)){
				joken2_2 = new String(inETMsg.getObject(KK0251ETMsg.GENE_ADD_DTM).toString());
			}

			String joken3_2 = "0";
			// 条件文定義
			String joken_1 = KK0251ETMsg.getDBColumnName(KK0251ETMsg.SVC_KEI_KAISEN_UCWK_NO);
			if(joken1_2 == null){
				joken_1 += " IS NULL ";
			}else{
				joken_1 += " = ? ";
			}

			String joken_2 = KK0251ETMsg.getDBColumnName(KK0251ETMsg.GENE_ADD_DTM);
			if(joken2_2 == null){
				joken_2 += " IS NULL ";
			}else{
				joken_2 += " = ? ";
			}

			String joken_3 = KK0251ETMsg.getDBColumnName(KK0251ETMsg.MK_FLG);
			if(joken3_2 == null){
				joken_3 += " IS NULL ";
			}else{
				joken_3 += " = ? ";
			}

			// チェック条件
			if (!inETMsg.isNull(KK0251ETMsg.SVC_KEI_KAISEN_UCWK_NO) && !inETMsg.isNull(KK0251ETMsg.GENE_ADD_DTM)) { 

				// ＳＱＬ文の組み立て
				sqlQuery.append("SELECT COUNT(*) CNT FROM ").append(KK0251ETMsg.getTableName()).append(" WHERE ")
					.append("(" + "(" + joken_1 + " AND " + joken_2 + " ) " + " AND " + joken_3 + " ) ");

				// ＳＱＬ文の解析
				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);
				}
				if(joken3_2 != null){
					CAANJDBCUtil.setParam(pstmtQuery, para_idx++ , joken3_2);
				}

				// ＳＱＬ文の実行
				rsltQuery = pstmtQuery.executeQuery();

				if(rsltQuery.next()){
				// 判定条件
					if(!(rsltQuery.getLong("CNT")>0)){
						inETMsg.set(KK0251ETMsg.SVC_KEI_KAISEN_UCWK_NO_ERR, errFlag);
						if("W".equals(errFlag.substring(0,1))){
							rtn = StatusCodes.WARNING;
						} else {
							rtn = StatusCodes.RELATION_ERR;
						}
					}
				}

			}

		} catch(SQLException e) {
			inETMsg.set(KK0251ETMsg.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(KK0251ETMsg.STATUS, StatusCodes.FIND_DB_ERR);
				throw new CAANRuntimeException(e);
			}
		}
		
		// ステータスのセット
		if (rtn > inETMsg.getInt(KK0251ETMsg.STATUS)) {
			inETMsg.set(KK0251ETMsg.STATUS, rtn);
		}

		return rtn;

	}

	/**
	 * IKK0251D002_制約ＮＯ1チェック
	 *
	 * @param inETMsg チェック対象のETMsg(KK0251ETMsg)
	 * @param inContext Agentから渡されたAgentDispatchContext
	 * @param errFlag ERRフラグ
	 * @return int チェック結果
	 */
	private int execIKK0251D002_1(CAANMsg inETMsg, AgentDispatchContext inContext, String errFlag){

		// ステータス
		int rtn = 0;

		Connection con = JSYejbConnection.getConnection(KK0251ETMsg.getTableName());

		PreparedStatement pstmtQuery = null;
		ResultSet rsltQuery = null;
		StringBuffer sqlQuery = new StringBuffer();

		try{

			// チェック条件定数
			// ＳＱＬ引数定義
			String joken1_2 = null;
			if(!inETMsg.isNull(KK0251ETMsg.SVC_KEI_KAISEN_UCWK_NO)){
				joken1_2 = new String(inETMsg.getObject(KK0251ETMsg.SVC_KEI_KAISEN_UCWK_NO).toString());
			}

			String joken2_2 = null;
			if(!inETMsg.isNull(KK0251ETMsg.GENE_ADD_DTM)){
				joken2_2 = new String(inETMsg.getObject(KK0251ETMsg.GENE_ADD_DTM).toString());
			}

			// 条件文定義
			String joken_1 = KK0251ETMsg.getDBColumnName(KK0251ETMsg.SVC_KEI_KAISEN_UCWK_NO);
			if(joken1_2 == null){
				joken_1 += " IS NULL ";
			}else{
				joken_1 += " = ? ";
			}

			String joken_2 = KK0251ETMsg.getDBColumnName(KK0251ETMsg.GENE_ADD_DTM);
			if(joken2_2 == null){
				joken_2 += " IS NULL ";
			}else{
				joken_2 += " = ? ";
			}

			// チェック条件
			if (!inETMsg.isNull(KK0251ETMsg.SVC_KEI_KAISEN_UCWK_NO) && !inETMsg.isNull(KK0251ETMsg.GENE_ADD_DTM)) { 

				// ＳＱＬ文の組み立て
				sqlQuery.append("SELECT COUNT(*) CNT FROM ").append(KK0251ETMsg.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(KK0251ETMsg.MSKM_DTL_NO_ERR, errFlag);
						if("W".equals(errFlag.substring(0,1))){
							rtn = StatusCodes.WARNING;
						} else {
							rtn = StatusCodes.RELATION_ERR;
						}
					}
				}

			}

		} catch(SQLException e) {
			inETMsg.set(KK0251ETMsg.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(KK0251ETMsg.STATUS, StatusCodes.FIND_DB_ERR);
				throw new CAANRuntimeException(e);
			}
		}
		
		// ステータスのセット
		if (rtn > inETMsg.getInt(KK0251ETMsg.STATUS)) {
			inETMsg.set(KK0251ETMsg.STATUS, rtn);
		}

		return rtn;

	}

	/**
	 * IKK0251D002_制約ＮＯ2チェック
	 *
	 * @param inETMsg チェック対象のETMsg(KK0251ETMsg)
	 * @param inContext Agentから渡されたAgentDispatchContext
	 * @param errFlag ERRフラグ
	 * @return int チェック結果
	 */
	private int execIKK0251D002_2(CAANMsg inETMsg, AgentDispatchContext inContext, String errFlag){

		// ステータス
		int rtn = 0;

		Connection con = JSYejbConnection.getConnection(KK0251ETMsg.getTableName());

		PreparedStatement pstmtQuery = null;
		ResultSet rsltQuery = null;
		StringBuffer sqlQuery = new StringBuffer();

		try{

			// チェック条件定数
			// ＳＱＬ引数定義
			String joken1_2 = null;
			if(!inETMsg.isNull(KK0251ETMsg.SVC_KEI_KAISEN_UCWK_NO)){
				joken1_2 = new String(inETMsg.getObject(KK0251ETMsg.SVC_KEI_KAISEN_UCWK_NO).toString());
			}

			// 条件文定義
			String joken_1 = KK0251ETMsg.getDBColumnName(KK0251ETMsg.SVC_KEI_KAISEN_UCWK_NO);
			if(joken1_2 == null){
				joken_1 += " IS NULL ";
			}else{
				joken_1 += " = ? ";
			}

			// チェック条件
			if (!inETMsg.isNull(KK0251ETMsg.SVC_KEI_KAISEN_UCWK_NO)) { 

				// ＳＱＬ文の組み立て
				sqlQuery.append("SELECT COUNT(*) CNT FROM ").append(KK0251ETMsg.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(KK0251ETMsg.MSKM_DTL_NO_ERR, errFlag);
						if("W".equals(errFlag.substring(0,1))){
							rtn = StatusCodes.WARNING;
						} else {
							rtn = StatusCodes.RELATION_ERR;
						}
					}
				}

			}

		} catch(SQLException e) {
			inETMsg.set(KK0251ETMsg.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(KK0251ETMsg.STATUS, StatusCodes.FIND_DB_ERR);
				throw new CAANRuntimeException(e);
			}
		}
		
		// ステータスのセット
		if (rtn > inETMsg.getInt(KK0251ETMsg.STATUS)) {
			inETMsg.set(KK0251ETMsg.STATUS, rtn);
		}

		return rtn;

	}

	/**
	 * IKK0251D002_制約ＮＯ5チェック
	 *
	 * @param inETMsg チェック対象のETMsg(KK0251ETMsg)
	 * @param inContext Agentから渡されたAgentDispatchContext
	 * @param errFlag ERRフラグ
	 * @return int チェック結果
	 */
	private int execIKK0251D002_5(CAANMsg inETMsg, AgentDispatchContext inContext, String errFlag){

		// ステータス
		int rtn = 0;

			// チェック条件定数
			// 制約部品引数定義
			// チェック条件
			if (!inETMsg.isNull(KK0251ETMsg.SKS_YO_KISN_PLACE_AD_RM_NO) && !inETMsg.isNull(KK0251ETMsg.MANSION_BUKKEN_NO)) { 
			// 判定条件
			if(!(JKKModelCommon.chkDbleAdrrmKK0251(inETMsg, inContext ) == false)){
					inETMsg.set(KK0251ETMsg.SKS_YO_KISN_PLACE_AD_RM_NO_ERR, errFlag);
					if("W".equals(errFlag.substring(0,1))){
						rtn = StatusCodes.WARNING;
					} else {
						rtn = StatusCodes.RELATION_ERR;
					}
				}
			}

		
		// ステータスのセット
		if (rtn > inETMsg.getInt(KK0251ETMsg.STATUS)) {
			inETMsg.set(KK0251ETMsg.STATUS, rtn);
		}

		return rtn;

	}

	/**
	 * IKK0251D005_制約ＮＯ1チェック
	 *
	 * @param inETMsg チェック対象のETMsg(KK0251ETMsg)
	 * @param inContext Agentから渡されたAgentDispatchContext
	 * @param errFlag ERRフラグ
	 * @return int チェック結果
	 */
	private int execIKK0251D005_1(CAANMsg inETMsg, AgentDispatchContext inContext, String errFlag){

		// ステータス
		int rtn = 0;

		Connection con = JSYejbConnection.getConnection(KK0251ETMsg.getTableName());

		PreparedStatement pstmtQuery = null;
		ResultSet rsltQuery = null;
		StringBuffer sqlQuery = new StringBuffer();

		try{

			// チェック条件定数
			// ＳＱＬ引数定義
			String joken1_2 = null;
			if(!inETMsg.isNull(KK0251ETMsg.SVC_KEI_KAISEN_UCWK_NO)){
				joken1_2 = new String(inETMsg.getObject(KK0251ETMsg.SVC_KEI_KAISEN_UCWK_NO).toString());
			}

			String joken2_2 = "0";
			// 条件文定義
			String joken_1 = KK0251ETMsg.getDBColumnName(KK0251ETMsg.SVC_KEI_KAISEN_UCWK_NO);
			if(joken1_2 == null){
				joken_1 += " IS NULL ";
			}else{
				joken_1 += " = ? ";
			}

			String joken_2 = KK0251ETMsg.getDBColumnName(KK0251ETMsg.MK_FLG);
			if(joken2_2 == null){
				joken_2 += " IS NULL ";
			}else{
				joken_2 += " = ? ";
			}

			// チェック条件
			if (!inETMsg.isNull(KK0251ETMsg.SVC_KEI_KAISEN_UCWK_NO)) { 

				// ＳＱＬ文の組み立て
				sqlQuery.append("SELECT COUNT(*) CNT FROM ").append(KK0251ETMsg.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(KK0251ETMsg.SVC_KEI_KAISEN_UCWK_NO_ERR, errFlag);
						if("W".equals(errFlag.substring(0,1))){
							rtn = StatusCodes.WARNING;
						} else {
							rtn = StatusCodes.RELATION_ERR;
						}
					}
				}

			}

		} catch(SQLException e) {
			inETMsg.set(KK0251ETMsg.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(KK0251ETMsg.STATUS, StatusCodes.FIND_DB_ERR);
				throw new CAANRuntimeException(e);
			}
		}
		
		// ステータスのセット
		if (rtn > inETMsg.getInt(KK0251ETMsg.STATUS)) {
			inETMsg.set(KK0251ETMsg.STATUS, rtn);
		}

		return rtn;

	}

	/**
	 * IKK0251D005_制約ＮＯ2チェック
	 *
	 * @param inETMsg チェック対象のETMsg(KK0251ETMsg)
	 * @param inContext Agentから渡されたAgentDispatchContext
	 * @param errFlag ERRフラグ
	 * @return int チェック結果
	 */
	private int execIKK0251D005_2(CAANMsg inETMsg, AgentDispatchContext inContext, String errFlag){

		// ステータス
		int rtn = 0;

		Connection con = JSYejbConnection.getConnection(KK0251ETMsg.getTableName());

		PreparedStatement pstmtQuery = null;
		ResultSet rsltQuery = null;
		StringBuffer sqlQuery = new StringBuffer();

		try{

			// チェック条件定数
			// ＳＱＬ引数定義
			String joken1_2 = null;
			if(!inETMsg.isNull(KK0251ETMsg.SVC_KEI_KAISEN_UCWK_NO)){
				joken1_2 = new String(inETMsg.getObject(KK0251ETMsg.SVC_KEI_KAISEN_UCWK_NO).toString());
			}

			String joken2_2 = null;
			if(!inETMsg.isNull(KK0251ETMsg.GENE_ADD_DTM)){
				joken2_2 = new String(inETMsg.getObject(KK0251ETMsg.GENE_ADD_DTM).toString());
			}

			// 条件文定義
			String joken_1 = KK0251ETMsg.getDBColumnName(KK0251ETMsg.SVC_KEI_KAISEN_UCWK_NO);
			if(joken1_2 == null){
				joken_1 += " IS NULL ";
			}else{
				joken_1 += " = ? ";
			}

			String joken_2 = KK0251ETMsg.getDBColumnName(KK0251ETMsg.GENE_ADD_DTM);
			if(joken2_2 == null){
				joken_2 += " IS NULL ";
			}else{
				joken_2 += " = ? ";
			}

			// チェック条件
			if (!inETMsg.isNull(KK0251ETMsg.SVC_KEI_KAISEN_UCWK_NO) && !inETMsg.isNull(KK0251ETMsg.GENE_ADD_DTM)) { 

				// ＳＱＬ文の組み立て
				sqlQuery.append("SELECT COUNT(*) CNT FROM ").append(KK0251ETMsg.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(KK0251ETMsg.SVC_KEI_KAISEN_UCWK_NO_ERR, errFlag);
						if("W".equals(errFlag.substring(0,1))){
							rtn = StatusCodes.WARNING;
						} else {
							rtn = StatusCodes.RELATION_ERR;
						}
					}
				}

			}

		} catch(SQLException e) {
			inETMsg.set(KK0251ETMsg.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(KK0251ETMsg.STATUS, StatusCodes.FIND_DB_ERR);
				throw new CAANRuntimeException(e);
			}
		}
		
		// ステータスのセット
		if (rtn > inETMsg.getInt(KK0251ETMsg.STATUS)) {
			inETMsg.set(KK0251ETMsg.STATUS, rtn);
		}

		return rtn;

	}

	/**
	 * IKK0251D005_制約ＮＯ7チェック
	 *
	 * @param inETMsg チェック対象のETMsg(KK0251ETMsg)
	 * @param inContext Agentから渡されたAgentDispatchContext
	 * @param errFlag ERRフラグ
	 * @return int チェック結果
	 */
	private int execIKK0251D005_7(CAANMsg inETMsg, AgentDispatchContext inContext, String errFlag){

		// ステータス
		int rtn = 0;

			// チェック条件定数
			// 制約部品引数定義
			// チェック条件
			if (!inETMsg.isNull(KK0251ETMsg.SKS_YO_KISN_PLACE_AD_RM_NO) && !inETMsg.isNull(KK0251ETMsg.MANSION_BUKKEN_NO)) { 
			// 判定条件
			if(!(JKKModelCommon.chkDbleAdrrmKK0251(inETMsg, inContext ) == false)){
					inETMsg.set(KK0251ETMsg.SKS_YO_KISN_PLACE_AD_RM_NO_ERR, errFlag);
					if("W".equals(errFlag.substring(0,1))){
						rtn = StatusCodes.WARNING;
					} else {
						rtn = StatusCodes.RELATION_ERR;
					}
				}
			}

		
		// ステータスのセット
		if (rtn > inETMsg.getInt(KK0251ETMsg.STATUS)) {
			inETMsg.set(KK0251ETMsg.STATUS, rtn);
		}

		return rtn;

	}

	/**
	 * IKK0251D006_制約ＮＯ1チェック
	 *
	 * @param inETMsg チェック対象のETMsg(KK0251ETMsg)
	 * @param inContext Agentから渡されたAgentDispatchContext
	 * @param errFlag ERRフラグ
	 * @return int チェック結果
	 */
	private int execIKK0251D006_1(CAANMsg inETMsg, AgentDispatchContext inContext, String errFlag){

		// ステータス
		int rtn = 0;

		Connection con = JSYejbConnection.getConnection(KK0251ETMsg.getTableName());

		PreparedStatement pstmtQuery = null;
		ResultSet rsltQuery = null;
		StringBuffer sqlQuery = new StringBuffer();

		try{

			// チェック条件定数
			// ＳＱＬ引数定義
			String joken1_2 = null;
			if(!inETMsg.isNull(KK0251ETMsg.SVC_KEI_KAISEN_UCWK_NO)){
				joken1_2 = new String(inETMsg.getObject(KK0251ETMsg.SVC_KEI_KAISEN_UCWK_NO).toString());
			}

			String joken2_2 = "0";
			// 条件文定義
			String joken_1 = KK0251ETMsg.getDBColumnName(KK0251ETMsg.SVC_KEI_KAISEN_UCWK_NO);
			if(joken1_2 == null){
				joken_1 += " IS NULL ";
			}else{
				joken_1 += " = ? ";
			}

			String joken_2 = KK0251ETMsg.getDBColumnName(KK0251ETMsg.MK_FLG);
			if(joken2_2 == null){
				joken_2 += " IS NULL ";
			}else{
				joken_2 += " = ? ";
			}

			// チェック条件
			if (!inETMsg.isNull(KK0251ETMsg.SVC_KEI_KAISEN_UCWK_NO)) { 

				// ＳＱＬ文の組み立て
				sqlQuery.append("SELECT COUNT(*) CNT FROM ").append(KK0251ETMsg.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(KK0251ETMsg.SVC_KEI_KAISEN_UCWK_NO_ERR, errFlag);
						if("W".equals(errFlag.substring(0,1))){
							rtn = StatusCodes.WARNING;
						} else {
							rtn = StatusCodes.RELATION_ERR;
						}
					}
				}

			}

		} catch(SQLException e) {
			inETMsg.set(KK0251ETMsg.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(KK0251ETMsg.STATUS, StatusCodes.FIND_DB_ERR);
				throw new CAANRuntimeException(e);
			}
		}
		
		// ステータスのセット
		if (rtn > inETMsg.getInt(KK0251ETMsg.STATUS)) {
			inETMsg.set(KK0251ETMsg.STATUS, rtn);
		}

		return rtn;

	}

	/**
	 * IKK0251D006_制約ＮＯ2チェック
	 *
	 * @param inETMsg チェック対象のETMsg(KK0251ETMsg)
	 * @param inContext Agentから渡されたAgentDispatchContext
	 * @param errFlag ERRフラグ
	 * @return int チェック結果
	 */
	private int execIKK0251D006_2(CAANMsg inETMsg, AgentDispatchContext inContext, String errFlag){

		// ステータス
		int rtn = 0;

		Connection con = JSYejbConnection.getConnection(KK0251ETMsg.getTableName());

		PreparedStatement pstmtQuery = null;
		ResultSet rsltQuery = null;
		StringBuffer sqlQuery = new StringBuffer();

		try{

			// チェック条件定数
			// ＳＱＬ引数定義
			String joken1_2 = null;
			if(!inETMsg.isNull(KK0251ETMsg.SVC_KEI_KAISEN_UCWK_NO)){
				joken1_2 = new String(inETMsg.getObject(KK0251ETMsg.SVC_KEI_KAISEN_UCWK_NO).toString());
			}

			String joken2_2 = null;
			if(!inETMsg.isNull(KK0251ETMsg.GENE_ADD_DTM)){
				joken2_2 = new String(inETMsg.getObject(KK0251ETMsg.GENE_ADD_DTM).toString());
			}

			// 条件文定義
			String joken_1 = KK0251ETMsg.getDBColumnName(KK0251ETMsg.SVC_KEI_KAISEN_UCWK_NO);
			if(joken1_2 == null){
				joken_1 += " IS NULL ";
			}else{
				joken_1 += " = ? ";
			}

			String joken_2 = KK0251ETMsg.getDBColumnName(KK0251ETMsg.GENE_ADD_DTM);
			if(joken2_2 == null){
				joken_2 += " IS NULL ";
			}else{
				joken_2 += " = ? ";
			}

			// チェック条件
			if (!inETMsg.isNull(KK0251ETMsg.SVC_KEI_KAISEN_UCWK_NO) && !inETMsg.isNull(KK0251ETMsg.GENE_ADD_DTM)) { 

				// ＳＱＬ文の組み立て
				sqlQuery.append("SELECT COUNT(*) CNT FROM ").append(KK0251ETMsg.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(KK0251ETMsg.SVC_KEI_KAISEN_UCWK_NO_ERR, errFlag);
						if("W".equals(errFlag.substring(0,1))){
							rtn = StatusCodes.WARNING;
						} else {
							rtn = StatusCodes.RELATION_ERR;
						}
					}
				}

			}

		} catch(SQLException e) {
			inETMsg.set(KK0251ETMsg.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(KK0251ETMsg.STATUS, StatusCodes.FIND_DB_ERR);
				throw new CAANRuntimeException(e);
			}
		}
		
		// ステータスのセット
		if (rtn > inETMsg.getInt(KK0251ETMsg.STATUS)) {
			inETMsg.set(KK0251ETMsg.STATUS, rtn);
		}

		return rtn;

	}

	/**
	 * IKK0251D007_制約ＮＯ1チェック
	 *
	 * @param inETMsg チェック対象のETMsg(KK0251ETMsg)
	 * @param inContext Agentから渡されたAgentDispatchContext
	 * @param errFlag ERRフラグ
	 * @return int チェック結果
	 */
	private int execIKK0251D007_1(CAANMsg inETMsg, AgentDispatchContext inContext, String errFlag){

		// ステータス
		int rtn = 0;

		Connection con = JSYejbConnection.getConnection(KK0251ETMsg.getTableName());

		PreparedStatement pstmtQuery = null;
		ResultSet rsltQuery = null;
		StringBuffer sqlQuery = new StringBuffer();

		try{

			// チェック条件定数
			// ＳＱＬ引数定義
			String joken1_2 = null;
			if(!inETMsg.isNull(KK0251ETMsg.SVC_KEI_KAISEN_UCWK_NO)){
				joken1_2 = new String(inETMsg.getObject(KK0251ETMsg.SVC_KEI_KAISEN_UCWK_NO).toString());
			}

			String joken2_2 = "0";
			// 条件文定義
			String joken_1 = KK0251ETMsg.getDBColumnName(KK0251ETMsg.SVC_KEI_KAISEN_UCWK_NO);
			if(joken1_2 == null){
				joken_1 += " IS NULL ";
			}else{
				joken_1 += " = ? ";
			}

			String joken_2 = KK0251ETMsg.getDBColumnName(KK0251ETMsg.MK_FLG);
			if(joken2_2 == null){
				joken_2 += " IS NULL ";
			}else{
				joken_2 += " = ? ";
			}

			// チェック条件
			if (!inETMsg.isNull(KK0251ETMsg.SVC_KEI_KAISEN_UCWK_NO)) { 

				// ＳＱＬ文の組み立て
				sqlQuery.append("SELECT COUNT(*) CNT FROM ").append(KK0251ETMsg.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(KK0251ETMsg.SVC_KEI_KAISEN_UCWK_NO_ERR, errFlag);
						if("W".equals(errFlag.substring(0,1))){
							rtn = StatusCodes.WARNING;
						} else {
							rtn = StatusCodes.RELATION_ERR;
						}
					}
				}

			}

		} catch(SQLException e) {
			inETMsg.set(KK0251ETMsg.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(KK0251ETMsg.STATUS, StatusCodes.FIND_DB_ERR);
				throw new CAANRuntimeException(e);
			}
		}
		
		// ステータスのセット
		if (rtn > inETMsg.getInt(KK0251ETMsg.STATUS)) {
			inETMsg.set(KK0251ETMsg.STATUS, rtn);
		}

		return rtn;

	}

	/**
	 * IKK0251D007_制約ＮＯ2チェック
	 *
	 * @param inETMsg チェック対象のETMsg(KK0251ETMsg)
	 * @param inContext Agentから渡されたAgentDispatchContext
	 * @param errFlag ERRフラグ
	 * @return int チェック結果
	 */
	private int execIKK0251D007_2(CAANMsg inETMsg, AgentDispatchContext inContext, String errFlag){

		// ステータス
		int rtn = 0;

		Connection con = JSYejbConnection.getConnection(KK0251ETMsg.getTableName());

		PreparedStatement pstmtQuery = null;
		ResultSet rsltQuery = null;
		StringBuffer sqlQuery = new StringBuffer();

		try{

			// チェック条件定数
			// ＳＱＬ引数定義
			String joken1_2 = null;
			if(!inETMsg.isNull(KK0251ETMsg.SVC_KEI_KAISEN_UCWK_NO)){
				joken1_2 = new String(inETMsg.getObject(KK0251ETMsg.SVC_KEI_KAISEN_UCWK_NO).toString());
			}

			String joken2_2 = null;
			if(!inETMsg.isNull(KK0251ETMsg.GENE_ADD_DTM)){
				joken2_2 = new String(inETMsg.getObject(KK0251ETMsg.GENE_ADD_DTM).toString());
			}

			// 条件文定義
			String joken_1 = KK0251ETMsg.getDBColumnName(KK0251ETMsg.SVC_KEI_KAISEN_UCWK_NO);
			if(joken1_2 == null){
				joken_1 += " IS NULL ";
			}else{
				joken_1 += " = ? ";
			}

			String joken_2 = KK0251ETMsg.getDBColumnName(KK0251ETMsg.GENE_ADD_DTM);
			if(joken2_2 == null){
				joken_2 += " IS NULL ";
			}else{
				joken_2 += " = ? ";
			}

			// チェック条件
			if (!inETMsg.isNull(KK0251ETMsg.SVC_KEI_KAISEN_UCWK_NO) && !inETMsg.isNull(KK0251ETMsg.GENE_ADD_DTM)) { 

				// ＳＱＬ文の組み立て
				sqlQuery.append("SELECT COUNT(*) CNT FROM ").append(KK0251ETMsg.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(KK0251ETMsg.SVC_KEI_KAISEN_UCWK_NO_ERR, errFlag);
						if("W".equals(errFlag.substring(0,1))){
							rtn = StatusCodes.WARNING;
						} else {
							rtn = StatusCodes.RELATION_ERR;
						}
					}
				}

			}

		} catch(SQLException e) {
			inETMsg.set(KK0251ETMsg.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(KK0251ETMsg.STATUS, StatusCodes.FIND_DB_ERR);
				throw new CAANRuntimeException(e);
			}
		}
		
		// ステータスのセット
		if (rtn > inETMsg.getInt(KK0251ETMsg.STATUS)) {
			inETMsg.set(KK0251ETMsg.STATUS, rtn);
		}

		return rtn;

	}

	/**
	 * IKK0251D008_制約ＮＯ1チェック
	 *
	 * @param inETMsg チェック対象のETMsg(KK0251ETMsg)
	 * @param inContext Agentから渡されたAgentDispatchContext
	 * @param errFlag ERRフラグ
	 * @return int チェック結果
	 */
	private int execIKK0251D008_1(CAANMsg inETMsg, AgentDispatchContext inContext, String errFlag){

		// ステータス
		int rtn = 0;

		Connection con = JSYejbConnection.getConnection(KK0251ETMsg.getTableName());

		PreparedStatement pstmtQuery = null;
		ResultSet rsltQuery = null;
		StringBuffer sqlQuery = new StringBuffer();

		try{

			// チェック条件定数
			// ＳＱＬ引数定義
			String joken1_2 = null;
			if(!inETMsg.isNull(KK0251ETMsg.SVC_KEI_KAISEN_UCWK_NO)){
				joken1_2 = new String(inETMsg.getObject(KK0251ETMsg.SVC_KEI_KAISEN_UCWK_NO).toString());
			}

			String joken2_2 = "0";
			// 条件文定義
			String joken_1 = KK0251ETMsg.getDBColumnName(KK0251ETMsg.SVC_KEI_KAISEN_UCWK_NO);
			if(joken1_2 == null){
				joken_1 += " IS NULL ";
			}else{
				joken_1 += " = ? ";
			}

			String joken_2 = KK0251ETMsg.getDBColumnName(KK0251ETMsg.MK_FLG);
			if(joken2_2 == null){
				joken_2 += " IS NULL ";
			}else{
				joken_2 += " = ? ";
			}

			// チェック条件
			if (!inETMsg.isNull(KK0251ETMsg.SVC_KEI_KAISEN_UCWK_NO)) { 

				// ＳＱＬ文の組み立て
				sqlQuery.append("SELECT COUNT(*) CNT FROM ").append(KK0251ETMsg.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(KK0251ETMsg.SVC_KEI_KAISEN_UCWK_NO_ERR, errFlag);
						if("W".equals(errFlag.substring(0,1))){
							rtn = StatusCodes.WARNING;
						} else {
							rtn = StatusCodes.RELATION_ERR;
						}
					}
				}

			}

		} catch(SQLException e) {
			inETMsg.set(KK0251ETMsg.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(KK0251ETMsg.STATUS, StatusCodes.FIND_DB_ERR);
				throw new CAANRuntimeException(e);
			}
		}
		
		// ステータスのセット
		if (rtn > inETMsg.getInt(KK0251ETMsg.STATUS)) {
			inETMsg.set(KK0251ETMsg.STATUS, rtn);
		}

		return rtn;

	}

	/**
	 * IKK0251D008_制約ＮＯ2チェック
	 *
	 * @param inETMsg チェック対象のETMsg(KK0251ETMsg)
	 * @param inContext Agentから渡されたAgentDispatchContext
	 * @param errFlag ERRフラグ
	 * @return int チェック結果
	 */
	private int execIKK0251D008_2(CAANMsg inETMsg, AgentDispatchContext inContext, String errFlag){

		// ステータス
		int rtn = 0;

		Connection con = JSYejbConnection.getConnection(KK0251ETMsg.getTableName());

		PreparedStatement pstmtQuery = null;
		ResultSet rsltQuery = null;
		StringBuffer sqlQuery = new StringBuffer();

		try{

			// チェック条件定数
			// ＳＱＬ引数定義
			String joken1_2 = null;
			if(!inETMsg.isNull(KK0251ETMsg.SVC_KEI_KAISEN_UCWK_NO)){
				joken1_2 = new String(inETMsg.getObject(KK0251ETMsg.SVC_KEI_KAISEN_UCWK_NO).toString());
			}

			String joken2_2 = null;
			if(!inETMsg.isNull(KK0251ETMsg.GENE_ADD_DTM)){
				joken2_2 = new String(inETMsg.getObject(KK0251ETMsg.GENE_ADD_DTM).toString());
			}

			// 条件文定義
			String joken_1 = KK0251ETMsg.getDBColumnName(KK0251ETMsg.SVC_KEI_KAISEN_UCWK_NO);
			if(joken1_2 == null){
				joken_1 += " IS NULL ";
			}else{
				joken_1 += " = ? ";
			}

			String joken_2 = KK0251ETMsg.getDBColumnName(KK0251ETMsg.GENE_ADD_DTM);
			if(joken2_2 == null){
				joken_2 += " IS NULL ";
			}else{
				joken_2 += " = ? ";
			}

			// チェック条件
			if (!inETMsg.isNull(KK0251ETMsg.SVC_KEI_KAISEN_UCWK_NO) && !inETMsg.isNull(KK0251ETMsg.GENE_ADD_DTM)) { 

				// ＳＱＬ文の組み立て
				sqlQuery.append("SELECT COUNT(*) CNT FROM ").append(KK0251ETMsg.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(KK0251ETMsg.SVC_KEI_KAISEN_UCWK_NO_ERR, errFlag);
						if("W".equals(errFlag.substring(0,1))){
							rtn = StatusCodes.WARNING;
						} else {
							rtn = StatusCodes.RELATION_ERR;
						}
					}
				}

			}

		} catch(SQLException e) {
			inETMsg.set(KK0251ETMsg.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(KK0251ETMsg.STATUS, StatusCodes.FIND_DB_ERR);
				throw new CAANRuntimeException(e);
			}
		}
		
		// ステータスのセット
		if (rtn > inETMsg.getInt(KK0251ETMsg.STATUS)) {
			inETMsg.set(KK0251ETMsg.STATUS, rtn);
		}

		return rtn;

	}

	/**
	 * IKK0251D009_制約ＮＯ1チェック
	 *
	 * @param inETMsg チェック対象のETMsg(KK0251ETMsg)
	 * @param inContext Agentから渡されたAgentDispatchContext
	 * @param errFlag ERRフラグ
	 * @return int チェック結果
	 */
	private int execIKK0251D009_1(CAANMsg inETMsg, AgentDispatchContext inContext, String errFlag){

		// ステータス
		int rtn = 0;

		Connection con = JSYejbConnection.getConnection(KK0251ETMsg.getTableName());

		PreparedStatement pstmtQuery = null;
		ResultSet rsltQuery = null;
		StringBuffer sqlQuery = new StringBuffer();

		try{

			// チェック条件定数
			// ＳＱＬ引数定義
			String joken1_2 = null;
			if(!inETMsg.isNull(KK0251ETMsg.SVC_KEI_KAISEN_UCWK_NO)){
				joken1_2 = new String(inETMsg.getObject(KK0251ETMsg.SVC_KEI_KAISEN_UCWK_NO).toString());
			}

			String joken2_2 = "0";
			// 条件文定義
			String joken_1 = KK0251ETMsg.getDBColumnName(KK0251ETMsg.SVC_KEI_KAISEN_UCWK_NO);
			if(joken1_2 == null){
				joken_1 += " IS NULL ";
			}else{
				joken_1 += " = ? ";
			}

			String joken_2 = KK0251ETMsg.getDBColumnName(KK0251ETMsg.MK_FLG);
			if(joken2_2 == null){
				joken_2 += " IS NULL ";
			}else{
				joken_2 += " = ? ";
			}

			// チェック条件
			if (!inETMsg.isNull(KK0251ETMsg.SVC_KEI_KAISEN_UCWK_NO)) { 

				// ＳＱＬ文の組み立て
				sqlQuery.append("SELECT COUNT(*) CNT FROM ").append(KK0251ETMsg.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(KK0251ETMsg.SVC_KEI_KAISEN_UCWK_NO_ERR, errFlag);
						if("W".equals(errFlag.substring(0,1))){
							rtn = StatusCodes.WARNING;
						} else {
							rtn = StatusCodes.RELATION_ERR;
						}
					}
				}

			}

		} catch(SQLException e) {
			inETMsg.set(KK0251ETMsg.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(KK0251ETMsg.STATUS, StatusCodes.FIND_DB_ERR);
				throw new CAANRuntimeException(e);
			}
		}
		
		// ステータスのセット
		if (rtn > inETMsg.getInt(KK0251ETMsg.STATUS)) {
			inETMsg.set(KK0251ETMsg.STATUS, rtn);
		}

		return rtn;

	}

	/**
	 * IKK0251D009_制約ＮＯ2チェック
	 *
	 * @param inETMsg チェック対象のETMsg(KK0251ETMsg)
	 * @param inContext Agentから渡されたAgentDispatchContext
	 * @param errFlag ERRフラグ
	 * @return int チェック結果
	 */
	private int execIKK0251D009_2(CAANMsg inETMsg, AgentDispatchContext inContext, String errFlag){

		// ステータス
		int rtn = 0;

		Connection con = JSYejbConnection.getConnection(KK0251ETMsg.getTableName());

		PreparedStatement pstmtQuery = null;
		ResultSet rsltQuery = null;
		StringBuffer sqlQuery = new StringBuffer();

		try{

			// チェック条件定数
			// ＳＱＬ引数定義
			String joken1_2 = null;
			if(!inETMsg.isNull(KK0251ETMsg.SVC_KEI_KAISEN_UCWK_NO)){
				joken1_2 = new String(inETMsg.getObject(KK0251ETMsg.SVC_KEI_KAISEN_UCWK_NO).toString());
			}

			String joken2_2 = null;
			if(!inETMsg.isNull(KK0251ETMsg.GENE_ADD_DTM)){
				joken2_2 = new String(inETMsg.getObject(KK0251ETMsg.GENE_ADD_DTM).toString());
			}

			// 条件文定義
			String joken_1 = KK0251ETMsg.getDBColumnName(KK0251ETMsg.SVC_KEI_KAISEN_UCWK_NO);
			if(joken1_2 == null){
				joken_1 += " IS NULL ";
			}else{
				joken_1 += " = ? ";
			}

			String joken_2 = KK0251ETMsg.getDBColumnName(KK0251ETMsg.GENE_ADD_DTM);
			if(joken2_2 == null){
				joken_2 += " IS NULL ";
			}else{
				joken_2 += " = ? ";
			}

			// チェック条件
			if (!inETMsg.isNull(KK0251ETMsg.SVC_KEI_KAISEN_UCWK_NO) && !inETMsg.isNull(KK0251ETMsg.GENE_ADD_DTM)) { 

				// ＳＱＬ文の組み立て
				sqlQuery.append("SELECT COUNT(*) CNT FROM ").append(KK0251ETMsg.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(KK0251ETMsg.SVC_KEI_KAISEN_UCWK_NO_ERR, errFlag);
						if("W".equals(errFlag.substring(0,1))){
							rtn = StatusCodes.WARNING;
						} else {
							rtn = StatusCodes.RELATION_ERR;
						}
					}
				}

			}

		} catch(SQLException e) {
			inETMsg.set(KK0251ETMsg.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(KK0251ETMsg.STATUS, StatusCodes.FIND_DB_ERR);
				throw new CAANRuntimeException(e);
			}
		}
		
		// ステータスのセット
		if (rtn > inETMsg.getInt(KK0251ETMsg.STATUS)) {
			inETMsg.set(KK0251ETMsg.STATUS, rtn);
		}

		return rtn;

	}

	/**
	 * IKK0251D010_制約ＮＯ1チェック
	 *
	 * @param inETMsg チェック対象のETMsg(KK0251ETMsg)
	 * @param inContext Agentから渡されたAgentDispatchContext
	 * @param errFlag ERRフラグ
	 * @return int チェック結果
	 */
	private int execIKK0251D010_1(CAANMsg inETMsg, AgentDispatchContext inContext, String errFlag){

		// ステータス
		int rtn = 0;

		Connection con = JSYejbConnection.getConnection(KK0251ETMsg.getTableName());

		PreparedStatement pstmtQuery = null;
		ResultSet rsltQuery = null;
		StringBuffer sqlQuery = new StringBuffer();

		try{

			// チェック条件定数
			// ＳＱＬ引数定義
			String joken1_2 = null;
			if(!inETMsg.isNull(KK0251ETMsg.SVC_KEI_KAISEN_UCWK_NO)){
				joken1_2 = new String(inETMsg.getObject(KK0251ETMsg.SVC_KEI_KAISEN_UCWK_NO).toString());
			}

			String joken2_2 = null;
			if(!inETMsg.isNull(KK0251ETMsg.GENE_ADD_DTM)){
				joken2_2 = new String(inETMsg.getObject(KK0251ETMsg.GENE_ADD_DTM).toString());
			}

			// 条件文定義
			String joken_1 = KK0251ETMsg.getDBColumnName(KK0251ETMsg.SVC_KEI_KAISEN_UCWK_NO);
			if(joken1_2 == null){
				joken_1 += " IS NULL ";
			}else{
				joken_1 += " = ? ";
			}

			String joken_2 = KK0251ETMsg.getDBColumnName(KK0251ETMsg.GENE_ADD_DTM);
			if(joken2_2 == null){
				joken_2 += " IS NULL ";
			}else{
				joken_2 += " = ? ";
			}

			// チェック条件
			if (!inETMsg.isNull(KK0251ETMsg.SVC_KEI_KAISEN_UCWK_NO) && !inETMsg.isNull(KK0251ETMsg.GENE_ADD_DTM)) { 

				// ＳＱＬ文の組み立て
				sqlQuery.append("SELECT COUNT(*) CNT FROM ").append(KK0251ETMsg.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(KK0251ETMsg.MSKM_DTL_NO_ERR, errFlag);
						if("W".equals(errFlag.substring(0,1))){
							rtn = StatusCodes.WARNING;
						} else {
							rtn = StatusCodes.RELATION_ERR;
						}
					}
				}

			}

		} catch(SQLException e) {
			inETMsg.set(KK0251ETMsg.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(KK0251ETMsg.STATUS, StatusCodes.FIND_DB_ERR);
				throw new CAANRuntimeException(e);
			}
		}
		
		// ステータスのセット
		if (rtn > inETMsg.getInt(KK0251ETMsg.STATUS)) {
			inETMsg.set(KK0251ETMsg.STATUS, rtn);
		}

		return rtn;

	}

	/**
	 * IKK0251D010_制約ＮＯ2チェック
	 *
	 * @param inETMsg チェック対象のETMsg(KK0251ETMsg)
	 * @param inContext Agentから渡されたAgentDispatchContext
	 * @param errFlag ERRフラグ
	 * @return int チェック結果
	 */
	private int execIKK0251D010_2(CAANMsg inETMsg, AgentDispatchContext inContext, String errFlag){

		// ステータス
		int rtn = 0;

		Connection con = JSYejbConnection.getConnection(KK0251ETMsg.getTableName());

		PreparedStatement pstmtQuery = null;
		ResultSet rsltQuery = null;
		StringBuffer sqlQuery = new StringBuffer();

		try{

			// チェック条件定数
			// ＳＱＬ引数定義
			String joken1_2 = null;
			if(!inETMsg.isNull(KK0251ETMsg.SVC_KEI_KAISEN_UCWK_NO)){
				joken1_2 = new String(inETMsg.getObject(KK0251ETMsg.SVC_KEI_KAISEN_UCWK_NO).toString());
			}

			// 条件文定義
			String joken_1 = KK0251ETMsg.getDBColumnName(KK0251ETMsg.SVC_KEI_KAISEN_UCWK_NO);
			if(joken1_2 == null){
				joken_1 += " IS NULL ";
			}else{
				joken_1 += " = ? ";
			}

			// チェック条件
			if (!inETMsg.isNull(KK0251ETMsg.SVC_KEI_KAISEN_UCWK_NO)) { 

				// ＳＱＬ文の組み立て
				sqlQuery.append("SELECT COUNT(*) CNT FROM ").append(KK0251ETMsg.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(KK0251ETMsg.MSKM_DTL_NO_ERR, errFlag);
						if("W".equals(errFlag.substring(0,1))){
							rtn = StatusCodes.WARNING;
						} else {
							rtn = StatusCodes.RELATION_ERR;
						}
					}
				}

			}

		} catch(SQLException e) {
			inETMsg.set(KK0251ETMsg.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(KK0251ETMsg.STATUS, StatusCodes.FIND_DB_ERR);
				throw new CAANRuntimeException(e);
			}
		}
		
		// ステータスのセット
		if (rtn > inETMsg.getInt(KK0251ETMsg.STATUS)) {
			inETMsg.set(KK0251ETMsg.STATUS, rtn);
		}

		return rtn;

	}

	/**
	 * IKK0251D010_制約ＮＯ5チェック
	 *
	 * @param inETMsg チェック対象のETMsg(KK0251ETMsg)
	 * @param inContext Agentから渡されたAgentDispatchContext
	 * @param errFlag ERRフラグ
	 * @return int チェック結果
	 */
	private int execIKK0251D010_5(CAANMsg inETMsg, AgentDispatchContext inContext, String errFlag){

		// ステータス
		int rtn = 0;

			// チェック条件定数
			// 制約部品引数定義
			// チェック条件
			if (!inETMsg.isNull(KK0251ETMsg.SKS_YO_KISN_PLACE_AD_RM_NO) && !inETMsg.isNull(KK0251ETMsg.MANSION_BUKKEN_NO)) { 
			// 判定条件
			if(!(JKKModelCommon.chkDbleAdrrmKK0251(inETMsg, inContext ) == false)){
					inETMsg.set(KK0251ETMsg.SKS_YO_KISN_PLACE_AD_RM_NO_ERR, errFlag);
					if("W".equals(errFlag.substring(0,1))){
						rtn = StatusCodes.WARNING;
					} else {
						rtn = StatusCodes.RELATION_ERR;
					}
				}
			}

		
		// ステータスのセット
		if (rtn > inETMsg.getInt(KK0251ETMsg.STATUS)) {
			inETMsg.set(KK0251ETMsg.STATUS, rtn);
		}

		return rtn;

	}

	/**
	 * IKK0341C020_制約ＮＯ2チェック
	 *
	 * @param inETMsg チェック対象のETMsg(KK0341ETMsg)
	 * @param inContext Agentから渡されたAgentDispatchContext
	 * @param errFlag ERRフラグ
	 * @return int チェック結果
	 */
	private int execIKK0341C020_2(CAANMsg inETMsg, AgentDispatchContext inContext, String errFlag){

		// ステータス
		int rtn = 0;

		Connection con = JSYejbConnection.getConnection(KK0251ETMsg.getTableName());

		PreparedStatement pstmtQuery = null;
		ResultSet rsltQuery = null;
		StringBuffer sqlQuery = new StringBuffer();

		try{

			// チェック条件定数
			// ＳＱＬ引数定義
			String joken1_2 = null;
			if(!inETMsg.isNull(KK0341ETMsg.SVC_KEI_KAISEN_UCWK_NO)){
				joken1_2 = new String(inETMsg.getObject(KK0341ETMsg.SVC_KEI_KAISEN_UCWK_NO).toString());
			}

			String joken2_2 = "0";
			// 条件文定義
			String joken_1 = KK0251ETMsg.getDBColumnName(KK0251ETMsg.SVC_KEI_KAISEN_UCWK_NO);
			if(joken1_2 == null){
				joken_1 += " IS NULL ";
			}else{
				joken_1 += " = ? ";
			}

			String joken_2 = KK0251ETMsg.getDBColumnName(KK0251ETMsg.MK_FLG);
			if(joken2_2 == null){
				joken_2 += " IS NULL ";
			}else{
				joken_2 += " = ? ";
			}

			// チェック条件
			if (!inETMsg.isNull(KK0341ETMsg.SVC_KEI_KAISEN_UCWK_NO)) { 

				// ＳＱＬ文の組み立て
				sqlQuery.append("SELECT COUNT(*) CNT FROM ").append(KK0251ETMsg.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(KK0341ETMsg.SVC_KEI_KAISEN_UCWK_NO_ERR, errFlag);
						if("W".equals(errFlag.substring(0,1))){
							rtn = StatusCodes.WARNING;
						} else {
							rtn = StatusCodes.RELATION_ERR;
						}
					}
				}

			}

		} catch(SQLException e) {
			inETMsg.set(KK0341ETMsg.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(KK0341ETMsg.STATUS, StatusCodes.FIND_DB_ERR);
				throw new CAANRuntimeException(e);
			}
		}
		
		// ステータスのセット
		if (rtn > inETMsg.getInt(KK0341ETMsg.STATUS)) {
			inETMsg.set(KK0341ETMsg.STATUS, rtn);
		}

		return rtn;

	}

	/**
	 * IKK0341D002_制約ＮＯ8チェック
	 *
	 * @param inETMsg チェック対象のETMsg(KK0341ETMsg)
	 * @param inContext Agentから渡されたAgentDispatchContext
	 * @param errFlag ERRフラグ
	 * @return int チェック結果
	 */
	private int execIKK0341D002_8(CAANMsg inETMsg, AgentDispatchContext inContext, String errFlag){

		// ステータス
		int rtn = 0;

		Connection con = JSYejbConnection.getConnection(KK0251ETMsg.getTableName());

		PreparedStatement pstmtQuery = null;
		ResultSet rsltQuery = null;
		StringBuffer sqlQuery = new StringBuffer();

		try{

			// チェック条件定数
			// ＳＱＬ引数定義
			String joken1_2 = null;
			if(!inETMsg.isNull(KK0341ETMsg.SVC_KEI_KAISEN_UCWK_NO)){
				joken1_2 = new String(inETMsg.getObject(KK0341ETMsg.SVC_KEI_KAISEN_UCWK_NO).toString());
			}

			String joken2_2 = "0";
			// 条件文定義
			String joken_1 = KK0251ETMsg.getDBColumnName(KK0251ETMsg.SVC_KEI_KAISEN_UCWK_NO);
			if(joken1_2 == null){
				joken_1 += " IS NULL ";
			}else{
				joken_1 += " = ? ";
			}

			String joken_2 = KK0251ETMsg.getDBColumnName(KK0251ETMsg.MK_FLG);
			if(joken2_2 == null){
				joken_2 += " IS NULL ";
			}else{
				joken_2 += " = ? ";
			}

			// チェック条件
			if (!inETMsg.isNull(KK0341ETMsg.SVC_KEI_KAISEN_UCWK_NO)) { 

				// ＳＱＬ文の組み立て
				sqlQuery.append("SELECT COUNT(*) CNT FROM ").append(KK0251ETMsg.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(KK0341ETMsg.SVC_KEI_KAISEN_UCWK_NO_ERR, errFlag);
						if("W".equals(errFlag.substring(0,1))){
							rtn = StatusCodes.WARNING;
						} else {
							rtn = StatusCodes.RELATION_ERR;
						}
					}
				}

			}

		} catch(SQLException e) {
			inETMsg.set(KK0341ETMsg.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(KK0341ETMsg.STATUS, StatusCodes.FIND_DB_ERR);
				throw new CAANRuntimeException(e);
			}
		}
		
		// ステータスのセット
		if (rtn > inETMsg.getInt(KK0341ETMsg.STATUS)) {
			inETMsg.set(KK0341ETMsg.STATUS, rtn);
		}

		return rtn;

	}

	/**
	 * IKK0341D021_制約ＮＯ3チェック
	 *
	 * @param inETMsg チェック対象のETMsg(KK0341ETMsg)
	 * @param inContext Agentから渡されたAgentDispatchContext
	 * @param errFlag ERRフラグ
	 * @return int チェック結果
	 */
	private int execIKK0341D021_3(CAANMsg inETMsg, AgentDispatchContext inContext, String errFlag){

		// ステータス
		int rtn = 0;

		Connection con = JSYejbConnection.getConnection(KK0251ETMsg.getTableName());

		PreparedStatement pstmtQuery = null;
		ResultSet rsltQuery = null;
		StringBuffer sqlQuery = new StringBuffer();

		try{

			// チェック条件定数
			// ＳＱＬ引数定義
			String joken1_2 = null;
			if(!inETMsg.isNull(KK0341ETMsg.SVC_KEI_KAISEN_UCWK_NO)){
				joken1_2 = new String(inETMsg.getObject(KK0341ETMsg.SVC_KEI_KAISEN_UCWK_NO).toString());
			}

			String joken2_2 = "0";
			// 条件文定義
			String joken_1 = KK0251ETMsg.getDBColumnName(KK0251ETMsg.SVC_KEI_KAISEN_UCWK_NO);
			if(joken1_2 == null){
				joken_1 += " IS NULL ";
			}else{
				joken_1 += " = ? ";
			}

			String joken_2 = KK0251ETMsg.getDBColumnName(KK0251ETMsg.MK_FLG);
			if(joken2_2 == null){
				joken_2 += " IS NULL ";
			}else{
				joken_2 += " = ? ";
			}

			// チェック条件
			if (!inETMsg.isNull(KK0341ETMsg.SVC_KEI_KAISEN_UCWK_NO)) { 

				// ＳＱＬ文の組み立て
				sqlQuery.append("SELECT COUNT(*) CNT FROM ").append(KK0251ETMsg.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(KK0341ETMsg.SVC_KEI_KAISEN_UCWK_NO_ERR, errFlag);
						if("W".equals(errFlag.substring(0,1))){
							rtn = StatusCodes.WARNING;
						} else {
							rtn = StatusCodes.RELATION_ERR;
						}
					}
				}

			}

		} catch(SQLException e) {
			inETMsg.set(KK0341ETMsg.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(KK0341ETMsg.STATUS, StatusCodes.FIND_DB_ERR);
				throw new CAANRuntimeException(e);
			}
		}
		
		// ステータスのセット
		if (rtn > inETMsg.getInt(KK0341ETMsg.STATUS)) {
			inETMsg.set(KK0341ETMsg.STATUS, rtn);
		}

		return rtn;

	}

	/**
	 * IKK1041D001_制約ＮＯ8チェック
	 *
	 * @param inETMsg チェック対象のETMsg(KK1041ETMsg)
	 * @param inContext Agentから渡されたAgentDispatchContext
	 * @param errFlag ERRフラグ
	 * @return int チェック結果
	 */
	private int execIKK1041D001_8(CAANMsg inETMsg, AgentDispatchContext inContext, String errFlag){

		// ステータス
		int rtn = 0;

		Connection con = JSYejbConnection.getConnection(KK0251ETMsg.getTableName());

		PreparedStatement pstmtQuery = null;
		ResultSet rsltQuery = null;
		StringBuffer sqlQuery = new StringBuffer();

		try{

			// チェック条件定数
			// ＳＱＬ引数定義
			String joken1_2 = null;
			if(!inETMsg.isNull(KK1041ETMsg.SVC_KEI_KAISEN_UCWK_NO)){
				joken1_2 = new String(inETMsg.getObject(KK1041ETMsg.SVC_KEI_KAISEN_UCWK_NO).toString());
			}

			String joken3_2 = "0";
			// 条件文定義
			String joken_1 = KK0251ETMsg.getDBColumnName(KK0251ETMsg.SVC_KEI_KAISEN_UCWK_NO);
			if(joken1_2 == null){
				joken_1 += " IS NULL ";
			}else{
				joken_1 += " = ? ";
			}

			String joken_3 = KK0251ETMsg.getDBColumnName(KK0251ETMsg.MK_FLG);
			if(joken3_2 == null){
				joken_3 += " IS NULL ";
			}else{
				joken_3 += " = ? ";
			}

			// チェック条件
			if (!inETMsg.isNull(KK1041ETMsg.SVC_KEI_KAISEN_UCWK_NO)) { 

				// ＳＱＬ文の組み立て
				sqlQuery.append("SELECT COUNT(*) CNT FROM ").append(KK0251ETMsg.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(KK1041ETMsg.SVC_KEI_KAISEN_UCWK_NO_ERR, errFlag);
						if("W".equals(errFlag.substring(0,1))){
							rtn = StatusCodes.WARNING;
						} else {
							rtn = StatusCodes.RELATION_ERR;
						}
					}
				}

			}

		} catch(SQLException e) {
			inETMsg.set(KK1041ETMsg.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(KK1041ETMsg.STATUS, StatusCodes.FIND_DB_ERR);
				throw new CAANRuntimeException(e);
			}
		}
		
		// ステータスのセット
		if (rtn > inETMsg.getInt(KK1041ETMsg.STATUS)) {
			inETMsg.set(KK1041ETMsg.STATUS, rtn);
		}

		return rtn;

	}

	/**
	 * IKK1081D001_制約ＮＯ9チェック
	 *
	 * @param inETMsg チェック対象のETMsg(KK1081ETMsg)
	 * @param inContext Agentから渡されたAgentDispatchContext
	 * @param errFlag ERRフラグ
	 * @return int チェック結果
	 */
	private int execIKK1081D001_9(CAANMsg inETMsg, AgentDispatchContext inContext, String errFlag){

		// ステータス
		int rtn = 0;

		Connection con = JSYejbConnection.getConnection(KK0251ETMsg.getTableName());

		PreparedStatement pstmtQuery = null;
		ResultSet rsltQuery = null;
		StringBuffer sqlQuery = new StringBuffer();

		try{

			// チェック条件定数
			// ＳＱＬ引数定義
			String joken1_2 = null;
			if(!inETMsg.isNull(KK1081ETMsg.SVC_KEI_KAISEN_UCWK_NO)){
				joken1_2 = new String(inETMsg.getObject(KK1081ETMsg.SVC_KEI_KAISEN_UCWK_NO).toString());
			}

			String joken2_2 = "0";
			// 条件文定義
			String joken_1 = KK0251ETMsg.getDBColumnName(KK0251ETMsg.SVC_KEI_KAISEN_UCWK_NO);
			if(joken1_2 == null){
				joken_1 += " IS NULL ";
			}else{
				joken_1 += " = ? ";
			}

			String joken_2 = KK0251ETMsg.getDBColumnName(KK0251ETMsg.MK_FLG);
			if(joken2_2 == null){
				joken_2 += " IS NULL ";
			}else{
				joken_2 += " = ? ";
			}

			// チェック条件
			if (!inETMsg.isNull(KK1081ETMsg.SVC_KEI_KAISEN_UCWK_NO)) { 

				// ＳＱＬ文の組み立て
				sqlQuery.append("SELECT COUNT(*) CNT FROM ").append(KK0251ETMsg.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(KK1081ETMsg.SVC_KEI_KAISEN_UCWK_NO_ERR, errFlag);
						if("W".equals(errFlag.substring(0,1))){
							rtn = StatusCodes.WARNING;
						} else {
							rtn = StatusCodes.RELATION_ERR;
						}
					}
				}

			}

		} catch(SQLException e) {
			inETMsg.set(KK1081ETMsg.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(KK1081ETMsg.STATUS, StatusCodes.FIND_DB_ERR);
				throw new CAANRuntimeException(e);
			}
		}
		
		// ステータスのセット
		if (rtn > inETMsg.getInt(KK1081ETMsg.STATUS)) {
			inETMsg.set(KK1081ETMsg.STATUS, rtn);
		}

		return rtn;

	}

	/**
	 * IKK1091D001_制約ＮＯ8チェック
	 *
	 * @param inETMsg チェック対象のETMsg(KK1091ETMsg)
	 * @param inContext Agentから渡されたAgentDispatchContext
	 * @param errFlag ERRフラグ
	 * @return int チェック結果
	 */
	private int execIKK1091D001_8(CAANMsg inETMsg, AgentDispatchContext inContext, String errFlag){

		// ステータス
		int rtn = 0;

		Connection con = JSYejbConnection.getConnection(KK0251ETMsg.getTableName());

		PreparedStatement pstmtQuery = null;
		ResultSet rsltQuery = null;
		StringBuffer sqlQuery = new StringBuffer();

		try{

			// チェック条件定数
			// ＳＱＬ引数定義
			String joken1_2 = null;
			if(!inETMsg.isNull(KK1091ETMsg.SVC_KEI_KAISEN_UCWK_NO)){
				joken1_2 = new String(inETMsg.getObject(KK1091ETMsg.SVC_KEI_KAISEN_UCWK_NO).toString());
			}

			String joken2_2 = "0";
			// 条件文定義
			String joken_1 = KK0251ETMsg.getDBColumnName(KK0251ETMsg.SVC_KEI_KAISEN_UCWK_NO);
			if(joken1_2 == null){
				joken_1 += " IS NULL ";
			}else{
				joken_1 += " = ? ";
			}

			String joken_2 = KK0251ETMsg.getDBColumnName(KK0251ETMsg.MK_FLG);
			if(joken2_2 == null){
				joken_2 += " IS NULL ";
			}else{
				joken_2 += " = ? ";
			}

			// チェック条件
			if (!inETMsg.isNull(KK1091ETMsg.SVC_KEI_KAISEN_UCWK_NO)) { 

				// ＳＱＬ文の組み立て
				sqlQuery.append("SELECT COUNT(*) CNT FROM ").append(KK0251ETMsg.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(KK1091ETMsg.SVC_KEI_KAISEN_UCWK_NO_ERR, errFlag);
						if("W".equals(errFlag.substring(0,1))){
							rtn = StatusCodes.WARNING;
						} else {
							rtn = StatusCodes.RELATION_ERR;
						}
					}
				}

			}

		} catch(SQLException e) {
			inETMsg.set(KK1091ETMsg.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(KK1091ETMsg.STATUS, StatusCodes.FIND_DB_ERR);
				throw new CAANRuntimeException(e);
			}
		}
		
		// ステータスのセット
		if (rtn > inETMsg.getInt(KK1091ETMsg.STATUS)) {
			inETMsg.set(KK1091ETMsg.STATUS, rtn);
		}

		return rtn;

	}

	/**
	 * IKK2961D001_制約ＮＯ3チェック
	 *
	 * @param inETMsg チェック対象のETMsg(KK2961ETMsg)
	 * @param inContext Agentから渡されたAgentDispatchContext
	 * @param errFlag ERRフラグ
	 * @return int チェック結果
	 */
	private int execIKK2961D001_3(CAANMsg inETMsg, AgentDispatchContext inContext, String errFlag){

		// ステータス
		int rtn = 0;

		Connection con = JSYejbConnection.getConnection(KK0251ETMsg.getTableName());

		PreparedStatement pstmtQuery = null;
		ResultSet rsltQuery = null;
		StringBuffer sqlQuery = new StringBuffer();

		try{

			// チェック条件定数
			String joken2_1 = new String();
			if(!inETMsg.isNull(KK2961ETMsg.SVKEI_GRP_SBT_CD)){
				joken2_1 = inETMsg.getObject(KK2961ETMsg.SVKEI_GRP_SBT_CD).toString();
			}

			String joken2_2 = "01";

			// ＳＱＬ引数定義
			String joken1_2 = null;
			if(!inETMsg.isNull(KK2961ETMsg.SVKEI_GRP_SKBT_NO)){
				joken1_2 = new String(inETMsg.getObject(KK2961ETMsg.SVKEI_GRP_SKBT_NO).toString());
			}

			// 条件文定義
			String joken_1 = KK0251ETMsg.getDBColumnName(KK0251ETMsg.SVC_KEI_KAISEN_UCWK_NO);
			if(joken1_2 == null){
				joken_1 += " IS NULL ";
			}else{
				joken_1 += " = ? ";
			}

			// チェック条件
			if (joken2_1.compareTo(joken2_2) == 0 && !inETMsg.isNull(KK2961ETMsg.SVKEI_GRP_SKBT_NO)) { 

				// ＳＱＬ文の組み立て
				sqlQuery.append("SELECT COUNT(*) CNT FROM ").append(KK0251ETMsg.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(KK2961ETMsg.SVKEI_GRP_SKBT_NO_ERR, errFlag);
						if("W".equals(errFlag.substring(0,1))){
							rtn = StatusCodes.WARNING;
						} else {
							rtn = StatusCodes.RELATION_ERR;
						}
					}
				}

			}

		} catch(SQLException e) {
			inETMsg.set(KK2961ETMsg.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(KK2961ETMsg.STATUS, StatusCodes.FIND_DB_ERR);
				throw new CAANRuntimeException(e);
			}
		}
		
		// ステータスのセット
		if (rtn > inETMsg.getInt(KK2961ETMsg.STATUS)) {
			inETMsg.set(KK2961ETMsg.STATUS, rtn);
		}

		return rtn;

	}

	/**
	 * IKK3011D001_制約ＮＯ2チェック
	 *
	 * @param inETMsg チェック対象のETMsg(KK3011ETMsg)
	 * @param inContext Agentから渡されたAgentDispatchContext
	 * @param errFlag ERRフラグ
	 * @return int チェック結果
	 */
	private int execIKK3011D001_2(CAANMsg inETMsg, AgentDispatchContext inContext, String errFlag){

		// ステータス
		int rtn = 0;

		Connection con = JSYejbConnection.getConnection(KK0251ETMsg.getTableName());

		PreparedStatement pstmtQuery = null;
		ResultSet rsltQuery = null;
		StringBuffer sqlQuery = new StringBuffer();

		try{

			// チェック条件定数
			// ＳＱＬ引数定義
			String joken1_2 = null;
			if(!inETMsg.isNull(KK3011ETMsg.SVC_KEI_KAISEN_UCWK_NO)){
				joken1_2 = new String(inETMsg.getObject(KK3011ETMsg.SVC_KEI_KAISEN_UCWK_NO).toString());
			}

			String joken2_2 = "0";
			// 条件文定義
			String joken_1 = KK0251ETMsg.getDBColumnName(KK0251ETMsg.SVC_KEI_KAISEN_UCWK_NO);
			if(joken1_2 == null){
				joken_1 += " IS NULL ";
			}else{
				joken_1 += " = ? ";
			}

			String joken_2 = KK0251ETMsg.getDBColumnName(KK0251ETMsg.MK_FLG);
			if(joken2_2 == null){
				joken_2 += " IS NULL ";
			}else{
				joken_2 += " = ? ";
			}

			// チェック条件
			if (!inETMsg.isNull(KK3011ETMsg.SVC_KEI_KAISEN_UCWK_NO)) { 

				// ＳＱＬ文の組み立て
				sqlQuery.append("SELECT COUNT(*) CNT FROM ").append(KK0251ETMsg.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(KK3011ETMsg.SVC_KEI_KAISEN_UCWK_NO_ERR, errFlag);
						if("W".equals(errFlag.substring(0,1))){
							rtn = StatusCodes.WARNING;
						} else {
							rtn = StatusCodes.RELATION_ERR;
						}
					}
				}

			}

		} catch(SQLException e) {
			inETMsg.set(KK3011ETMsg.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(KK3011ETMsg.STATUS, StatusCodes.FIND_DB_ERR);
				throw new CAANRuntimeException(e);
			}
		}
		
		// ステータスのセット
		if (rtn > inETMsg.getInt(KK3011ETMsg.STATUS)) {
			inETMsg.set(KK3011ETMsg.STATUS, rtn);
		}

		return rtn;

	}

	/**
	 * IKK3131D001_制約ＮＯ2チェック
	 *
	 * @param inETMsg チェック対象のETMsg(KK3131ETMsg)
	 * @param inContext Agentから渡されたAgentDispatchContext
	 * @param errFlag ERRフラグ
	 * @return int チェック結果
	 */
	private int execIKK3131D001_2(CAANMsg inETMsg, AgentDispatchContext inContext, String errFlag){

		// ステータス
		int rtn = 0;

		Connection con = JSYejbConnection.getConnection(KK0251ETMsg.getTableName());

		PreparedStatement pstmtQuery = null;
		ResultSet rsltQuery = null;
		StringBuffer sqlQuery = new StringBuffer();

		try{

			// ＳＱＬ引数定義
			String joken1_2 = null;
			if(!inETMsg.isNull(KK3131ETMsg.SVC_KEI_KAISEN_UCWK_NO)){
				joken1_2 = new String(inETMsg.getObject(KK3131ETMsg.SVC_KEI_KAISEN_UCWK_NO).toString());
			}

			String joken2_2 = "0";
			// 条件文定義
			String joken_1 = KK0251ETMsg.getDBColumnName(KK0251ETMsg.SVC_KEI_KAISEN_UCWK_NO);
			if(joken1_2 == null){
				joken_1 += " IS NULL ";
			}else{
				joken_1 += " = ? ";
			}

			String joken_2 = KK0251ETMsg.getDBColumnName(KK0251ETMsg.MK_FLG);
			if(joken2_2 == null){
				joken_2 += " IS NULL ";
			}else{
				joken_2 += " = ? ";
			}


			// ＳＱＬ文の組み立て
			sqlQuery.append("SELECT COUNT(*) CNT FROM ").append(KK0251ETMsg.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(KK3131ETMsg.SVC_KEI_KAISEN_UCWK_NO_ERR, errFlag);
					if("W".equals(errFlag.substring(0,1))){
						rtn = StatusCodes.WARNING;
					} else {
						rtn = StatusCodes.RELATION_ERR;
					}
				}
			}

		} catch(SQLException e) {
			inETMsg.set(KK3131ETMsg.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(KK3131ETMsg.STATUS, StatusCodes.FIND_DB_ERR);
				throw new CAANRuntimeException(e);
			}
		}
		
		// ステータスのセット
		if (rtn > inETMsg.getInt(KK3131ETMsg.STATUS)) {
			inETMsg.set(KK3131ETMsg.STATUS, rtn);
		}

		return rtn;

	}

}

