package com.ejie.m62fb.dao.registroVPP;

import com.ejie.m62fb.dao.SQLGenericas;
import com.ejie.m62fb.utils.constants.BDConstantes;

public class PromocionDaoSql {

	/**
	 * StringBuilder initilization value
	 */
	public static final int STRING_BUILDER_INIT = 4096;
	public static final String SEQUENCE_NAME = "";

	public static final String PK = "ID_M62E24T0";
    public static final String ALIAS_PROMOCION = "PROMO";
    public static final String ALIAS_EMPLAZAMIENTO = "EMP";

	public static final String SQL_SELECT = "SELECT ID_M62E24T0, NUM_EXPEDIENTE "
			+ SQLGenericas.getSqlCamposAbstractClass(null);

	public static final String SQL_FROM = " FROM " + BDConstantes.PROMOCION;

	public static final String SQL_WHERE_ALL = " WHERE 1=1 ";

	public static final String SQL_WHERE_ID = SQL_WHERE_ALL + " AND "
			+ "ID_M62E24T0 = ?";

	public static final String SQL_FIND = SQL_SELECT + SQL_FROM + SQL_WHERE_ID;

	public static final String SQL_FIND_ALL = SQL_SELECT + SQL_FROM;

	public static final String SQL_FIND_EXP_INICIAL ="SELECT * FROM (SELECT rownum rnum, b.* FROM (SELECT DISTINCT(ID_M62E24T0),NUM_EXPEDIENTE  FROM(";
	public static final String SQL_FIND_EXP_PROMO ="SELECT ID_M62E24T0, NUM_EXPEDIENTE from "+ 
	BDConstantes.PROMOCION + SQL_WHERE_ALL + " AND UPPER(NUM_EXPEDIENTE) like ? ESCAPE  '\\' ";
	public static final String SQL_FIND_EXP_UNION =" UNION ";
	public static final String SQL_FIND_EXP_EMPLAZ ="SELECT "
	        + PromocionDaoSql.ALIAS_PROMOCION
	        +".ID_M62E24T0, "
            + PromocionDaoSql.ALIAS_PROMOCION
            +".NUM_EXPEDIENTE from "+ BDConstantes.EMPLAZAMIENTO_PROMOCION
            +" "
            + PromocionDaoSql.ALIAS_EMPLAZAMIENTO
            +" inner join "
            + BDConstantes.PROMOCION
            +" "
            + PromocionDaoSql.ALIAS_PROMOCION
            +" on "
            + PromocionDaoSql.ALIAS_PROMOCION
            +"."
            +PK
            +"="
            + PromocionDaoSql.ALIAS_EMPLAZAMIENTO
            +"."
            +PK
	+" WHERE "
	+ PromocionDaoSql.ALIAS_EMPLAZAMIENTO
	+ ".ID_PROVINCIA = ? AND "
	+ PromocionDaoSql.ALIAS_EMPLAZAMIENTO
	+ ".ID_MUNICIPIO=? AND "
	+ PromocionDaoSql.ALIAS_EMPLAZAMIENTO
	+ ".ID_CALLE = lpad(?,5,'0') AND ("
	+ PromocionDaoSql.ALIAS_EMPLAZAMIENTO
	+ ".NUMERO=? OR "
	+ PromocionDaoSql.ALIAS_EMPLAZAMIENTO
	+ ".COD_PORTAL_OBRA=?)" ;
	public static final String SQL_FIND_EXP_FIN =" )a ORDER BY NUM_EXPEDIENTE)b)   where rnum > 0 and rnum < 21";
}