function createDataset(fields, constraints, sortFields) {
	// 	Criando a estrutura do dataset de retorno
 
	var jndiName = "java:/jdbc/CorporeRM";
	var sql		 = "";	
	try
	{		
		sql =   "SELECT VLOTEEPI.CA" +
		"  ,VLOTEEPI.CODEPI" +
		"  ,VCATALOGOEPI.NOME AS NOMEEPI" +
		"  ,VLOTEEPI.CODSECAO" +
		"  ,VLOTEEPI.IDLOTE" +
		"  ,ISNULL(CONVERT(varchar(MAX), VLOTEEPI.DTAQUISICAO, 103), '') DTAQUISICAO" +
		"  ,VLOTEEPI.DTVALIDADECA as VALIDADE" +
		"	FROM VCATALOGOEPI" +
		"	INNER JOIN VLOTEEPI WITH(NOLOCK) ON VLOTEEPI.CODCOLIGADA = VCATALOGOEPI.CODCOLIGADA" +
		" 		AND VLOTEEPI.CODEPI = VCATALOGOEPI.CODEPI" +
		"	LEFT JOIN VEPISEGURANCA WITH(NOLOCK) ON VEPISEGURANCA.CODCOLIGADA = VCATALOGOEPI.CODCOLIGADA" +
		" 		AND VEPISEGURANCA.CODEPI = VCATALOGOEPI.CODEPI" +
		"	WHERE  VLOTEEPI.INVALIDO = 0 AND VCATALOGOEPI.INATIVA = 0";		
//		if(constraints != null && constraints.length > 0){
//			sql +=  "	AND VCATALOGOEPI.CODCOLIGADA = " + constraints[0].initialValue;				
//						
//		}
		
		if(constraints != null && constraints.length > 0){
			
			var quantidade = constraints.length;
			log.info("Quantidade de constraints " + quantidade);
			for (var i = 0; i < constraints.length; i++) {
				log.info("Constraint " + i + " nome " + constraints[i].fieldName + " valor " + constraints[i].initialValue );
									
				
				
					if(constraints[i].fieldName != 'CODCOLIGADA'){
						if(constraints[i].fieldName == 'NOME' || constraints[i].fieldName == 'NOMEEPI' || constraints[i].fieldName == 'CODEPI'){
							
							sql +=  " 	AND  ( VCATALOGOEPI.NOME LIKE '%" + constraints[i].initialValue+"%'" + "" +										
							" 	OR   VCATALOGOEPI.CODEPI LIKE '%" + constraints[i].initialValue+"%')";
							
						}else{
							sql +=  "	AND "+constraints[i].fieldName+" LIKE '%" + constraints[i].initialValue+"%'";
						}
						
					}else{						
						sql +=  " 	AND  VCATALOGOEPI."+constraints[i].fieldName+" = '" + constraints[i].initialValue+"'";						
					}
					
				
				
			}
			
		}


		sql += 	"	GROUP BY VLOTEEPI.CA" +
				"  ,VLOTEEPI.CODEPI" +
				"  ,VCATALOGOEPI.NOME" +
				"  ,VLOTEEPI.CODSECAO" +
				"  ,VLOTEEPI.IDLOTE" +
				"  ,CONVERT(varchar(MAX), VLOTEEPI.DTAQUISICAO, 103)" +
				"  , VLOTEEPI.DTVALIDADECA ORDER BY VLOTEEPI.CODEPI";		
								
 
		log.info("CorporeRM_RH CatalogoEPI=> "+sql);

		var dsBusca = DatasetFactory.getDataset("dsSQL", new Array(sql, jndiName), null, null);				 		
	}
	catch (e) {
		throw e.message;
	}
  
	return dsBusca;
}