I'm getting an error while performing this select
sb = New StringBuilder
sb.Append(" SELECT ")
sb.Append(" SE.NU_SERIE_NF, ")
sb.Append(" SE.NU_NF, ")
sb.Append(" SE.DH_ENTREGA, ")
sb.Append(" SE.DH_IMPORTACAO, ")
sb.Append(" SE.ARMAZEM, ")
sb.Append(" SE.TRANSPORTADORA ")
sb.Append(" FROM ")
sb.Append(" SEP_ENTREGA SE ")
sb.Append(" WHERE ")
sb.Append(" SE.NU_NF IN (" & nuNota.ToString() & ") AND ")
sb.Append(" SE.NU_SERIE_NF IN (" & nuSerieNota.Distinct().ToList().FirstOrDefault().ToString() & ") ")
dtEmail = ListarDados(sb.ToString, conexao)
The error happens in this line sb.Append(" SE.NU_NF IN (" & nuNota.ToString() & ") AND ")
because the result has a thousand lines or more, something that the select in Oracle does not accept.
Code that populates variable nuNota
:
'Monta lista com os Números de Nota
Dim nuNota As String = ""
Dim nuSerieNota As String = ""
For i As Integer = 0 To listaNotaDHSolColeta.Count - 1
nuNota += listaNotaDHSolColeta.Item(i).nuNota.ToString()
nuSerieNota += listaNotaDHSolColeta.Item(i).nuSerieNota.ToString()
If i < listaNotaDHSolColeta.Count - 1 Then
nuNota += ","
nuSerieNota += ","
End If
Next
I searched the net, but I could not solve this problem.
My question is, how can I split this list into 2 parts, so I can search the select?