package gf;

import org.opengion.fukurou.business.BizLogic_ENTRY;

public class GF9540S extends BizLogic_ENTRY {

	protected boolean check() {
		return must( "SYSTEM_ID" );
	}

	protected boolean logic() {
		String sql = "select " + "SYSTEM_ID, LANG, CLM, NAME_JA, LABEL_NAME, KBSAKU, CDTAN, '1' AS ONMARK " + "from GF41 " + "where FGJ in ('0','1') ";

		if( var( "SYSTEM_ID" ) != null && var( "SYSTEM_ID" ).length() > 0 ) {
			sql += " and SYSTEM_ID = '" + var( "SYSTEM_ID" ) + "'";
		}
		if( var( "LANG" ) != null && var( "LANG" ).length() > 0 ) {
			sql += " and LANG = '" + var( "LANG" ) + "'";
		}
		if( var( "CLM" ) != null && var( "CLM" ).length() > 0 ) {
			sql += " and CLM = '" + var( "CLM" ) + "'";
		}
		if( var( "NAME_JA" ) != null && var( "NAME_JA" ).length() > 0 ) {
			sql += " and NAME_JA like '" + var( "NAME_JA" ) + "'";
		}
		if( var( "LABEL_NAME" ) != null && var( "LABEL_NAME" ).length() > 0 ) {
			sql += " and LABEL_NAME like '" + var( "LABEL_NAME" ) + "'";
		}
		if( var( "KBSAKU" ) != null && var( "KBSAKU" ).length() > 0 ) {
			sql += " and KBSAKU = '" + var( "KBSAKU" ) + "'";
		}

		if( var( "ORDER_BY" ) != null && var( "ORDER_BY" ).length() > 0 ) {
			sql += " order by " + var( "ORDER_BY" );
		}
		else {
			sql += " order by SYSTEM_ID,CLM,LANG ";
		}

		rtn( sql );

		return true;
	}
}
