0
How to create a query for the Oracle database by returning a list of orders according to a date range?
Follows the code currently used:
if (opcaoBusca.getSelectedIndex() == 0) {
JOptionPane.showMessageDialog(null,
"Escolha uma Opção de Busca!");
} else if (opcaoBusca.getSelectedIndex() == 1) {
RS = stmt.executeQuery("select numped FROM PCPEDC WHERE DATA > '10/01/2014' and numped = " + BuscaCodigo);
while (RS.next()) {
int Num = RS.getInt("numped");
consulta = false;
JOptionPane.showMessageDialog(null, "Dados Encontrado!!!!");
}
} else if (opcaoBusca.getSelectedIndex() == 2) {
RS = stmt.executeQuery("SELECT Data FROM PCPEDC WHERE Data BETWEEN " + Dtincial + "AND" + Dtfinal);
while (RS.next()) {
int Num = RS.getInt("numped");
Could you please ask a little better? I don’t quite understand.
– PauloHDSousa
Data
is a reserved word in multiple SQL dialects. Never use this as a field name. Also, post more code details. How you declare variables?– Victor Stafusa
User has to enter Date 1 and Date 2 so I can have the request number of the bank that corresponds to that period
– Wesley Costa
How do you declare variables? What is the type of
DataIni
,DataFim
,RS
andstmt
? You use atry-catch
somewhere? Give the code of a method that is compilable.– Victor Stafusa
That does not compile:
int BuscaCodigo = Integer.parseInt(entBusca.getText()); ResultSet RS = null;
int BuscaCodigo = Integer.parseInt(DataIni.getText()); ResultSet RS = null;
. Variables are duplicated. Also, because you are reading a date withparseInt
?– Victor Stafusa