Exemplo n.º 1
0
  private List<String> getCategoryNameStartWith(
      Connection pConn, int pStoreId, String pName, int pMaxRows) throws Exception {

    List<String> list = new ArrayList<String>();

    String reqName = pName.toUpperCase().replaceAll("'", "''");
    String sql =
        "SELECT DISTINCT JD_CATEGORY1 FROM DW_CATEGORY_DIM WHERE STORE_DIM_ID = ? AND UPPER(JD_CATEGORY1) LIKE '"
            + reqName
            + "%' ORDER BY JD_CATEGORY1";

    PreparedStatement pstmt = pConn.prepareStatement(sql);

    pstmt.setInt(1, pStoreId);

    pstmt.setMaxRows(pMaxRows);

    ResultSet rs = pstmt.executeQuery();
    while (rs.next()) {
      list.add(rs.getString(1));
    }

    return list;
  }