public String buildQueryWithParams(String docTableName) throws SQLException {
        String readyQuery="";
        //Checking if user select any particular document number
        if (selectedDocsByID.size()==0){
            if (isDocDateExistsInTable(docTableName)) {
                readyQuery = "select * from " + docTableName + " where DocDate BETWEEN '" + selectedDates.get(0) + "' AND '" + selectedDates.get(1) + "'";
                foundedTableWithDocDate.add(docTableName);
                foundedTablesCount++;
            }else{
                readyQuery = "select * from " + docTableName + " where ChID IN (select CHiD from " + foundedTableWithDocDate.get(foundedTablesCount-1) + " where DocDate BETWEEN '" + selectedDates.get(0) + "' AND '" + selectedDates.get(1) + "')";
            }
        }
        else
        {
            String ChID = "";
            for (int i=0;i<selectedDocsByID.size();i++){
                if (selectedDocsByID.size()==1){
                    ChID += selectedDocsByID.get(i);
                }
                if (selectedDocsByID.size()>1 && selectedDocsByID.size()!=1){
                    ChID += selectedDocsByID.get(i)+",";
                }
                if (i==selectedDocsByID.size()-1 && selectedDocsByID.size()!=1){
                    ChID += selectedDocsByID.get(i);
                }
            }
            readyQuery = "select * from " + docTableName + " where ChID IN("+ChID+")";
        }
        return readyQuery;
    }