Bom dia a todos!
Estive elaborando um comando SQL utilizando a ferramenta PL/SQL Developer e a mesma é executada normalmente sem erros. Ao transferir este comando para a aplicação, esta retorando o seguinte erro ?java.sql.SQLException: ORA-00923: palavra-chave FROM não localizada onde esperada?. Conforme foi dito o comando está correto pois executou no PL/SQL, acredito que esteja fazendo algo de errado na aplicação.
A princípio, achei que a variável que recebe o comando poderia ter algum tipo de limitação, pois o comando é relativamente complexo, sempre executei comandos da mesma forma, mas nunca com esta complexidade, portanto não sei se o método utilizado é o mais adequado.
Segue abaixo o comando SQL citado acima:
Sql = "Select E135Ane.CodEmp,"
+ " E135Ane.CodFil,"
+ " E135Ane.NumAne,"
+ " E135Ane.DatGer,"
+ " E135Ane.HorGer,"
+ " (Select Count(CodEmp)"
+ " From E135Pfa "
+ " Where E135Pfa.CodEmp = E135Ane.CodEmp"
+ " and E135Pfa.CodFil = E135Ane.CodFil"
+ " and E135Pfa.NumAne = E135Ane.NumAne) Qtd_PFA,"
+ " (Select Sum(PesBru)"
+ " From E135Pfa"
+ " Where E135Pfa.CodEmp = E135Ane.CodEmp"
+ " and E135Pfa.CodFil = E135Ane.CodFil"
+ " and E135Pfa.NumAne = E135Ane.NumAne) Peso_Bruto,"
+ " NVL((Select Min(USU_T135Pes.USU_DatCon)"
+ " From USU_T135Pes"
+ " Where USU_T135Pes.USU_CodEmp = E135Ane.CodEmp"
+ " and USU_T135Pes.USU_CodFil = E135Ane.CodFil"
+ " and USU_T135Pes.USU_NumAne = E135Ane.NumAne),"
+ " TO_DATE('31/12/1900','DD/MM/YYYY')) Data_Inicio_Leitura,"
+ " NVL((Select Min(USU_T135Pes.USU_HorCon)"
+ " From USU_T135Pes"
+ " Where USU_T135Pes.USU_CodEmp = E135Ane.CodEmp"
+ " and USU_T135Pes.USU_CodFil = E135Ane.CodFil"
+ " and USU_T135Pes.USU_NumAne = E135Ane.NumAne"
+ " and USU_T135Pes.USU_DatCon = (Select Min(B.USU_DatCon)"
+ " From USU_T135Pes B"
+ " Where B.USU_CodEmp = USU_T135Pes.USU_CodEmp"
+ " and B.USU_CodFil = USU_T135Pes.USU_CodFil"
+ " and B.USU_NumAne = USU_T135Pes.USU_NumAne)),0) Hora_Inicio_Leitura,"
+ " NVL((Select Max(USU_T135Pes.USU_DatCon)"
+ " From USU_T135Pes"
+ " Where USU_T135Pes.USU_CodEmp = E135Ane.CodEmp"
+ " and USU_T135Pes.USU_CodFil = E135Ane.CodFil"
+ " and USU_T135Pes.USU_NumAne = E135Ane.NumAne),"
+ " TO_DATE('31/12/1900','DD/MM/YYYY')) Data_Fim_Leitura,"
+ " NVL((Select Max(USU_T135Pes.USU_HorCon)"
+ " From USU_T135Pes"
+ " Where USU_T135Pes.USU_CodEmp = E135Ane.CodEmp"
+ " and USU_T135Pes.USU_CodFil = E135Ane.CodFil"
+ " and USU_T135Pes.USU_NumAne = E135Ane.NumAne"
+ " and USU_T135Pes.USU_DatCon = (Select Max(B.USU_DatCon)"
+ " From USU_T135Pes B"
+ " Where B.USU_CodEmp = USU_T135Pes.USU_CodEmp"
+ " and B.USU_CodFil = USU_T135Pes.USU_CodFil"
+ " and B.USU_NumAne = USU_T135Pes.USU_NumAne)),0) Hora_Fim_Leitura,"
+ " NVL((Select Min(USU_T135Lig.USU_DatCon)"
+ " From USU_T135Lig"
+ " Where USU_T135Lig.USU_CodEmp = E135Ane.CodEmp"
+ " and USU_T135Lig.USU_CodFil = E135Ane.CodFil"
+ " and USU_T135Lig.USU_NumAne = E135Ane.NumAne),"
+ " TO_DATE('31/12/1900','DD/MM/YYYY')) Data_Inicio_Atualização,"
+ " NVL((Select Min(USU_T135Lig.USU_HorCon)"
+ " From USU_T135Lig"
+ " Where USU_T135Lig.USU_CodEmp = E135Ane.CodEmp"
+ " and USU_T135Lig.USU_CodFil = E135Ane.CodFil"
+ " and USU_T135Lig.USU_NumAne = E135Ane.NumAne"
+ " and USU_T135Lig.USU_DatCon = (Select Min(B.USU_DatCon)"
+ " From USU_T135Lig B"
+ " Where B.USU_CodEmp = USU_T135Lig.USU_CodEmp"
+ " and B.USU_CodFil = USU_T135Lig.USU_CodFil"
+ " and B.USU_NumAne = USU_T135Lig.USU_NumAne)),0) Hora_Inicio_Atualização,"
+ " NVL((Select Max(USU_T135Lig.USU_DatCon)"
+ " From USU_T135Lig"
+ " Where USU_T135Lig.USU_CodEmp = E135Ane.CodEmp"
+ " and USU_T135Lig.USU_CodFil = E135Ane.CodFil"
+ " and USU_T135Lig.USU_NumAne = E135Ane.NumAne),"
+ " TO_DATE('31/12/1900','DD/MM/YYYY')) Data_Fim_Atualização,"
+ " NVL((Select Max(USU_T135Lig.USU_HorCon)"
+ " From USU_T135Lig"
+ " Where USU_T135Lig.USU_CodEmp = E135Ane.CodEmp"
+ " and USU_T135Lig.USU_CodFil = E135Ane.CodFil"
+ " and USU_T135Lig.USU_NumAne = E135Ane.NumAne"
+ " and USU_T135Lig.USU_DatCon = (Select Max(B.USU_DatCon)"
+ " From USU_T135Lig B"
+ " Where B.USU_CodEmp = USU_T135Lig.USU_CodEmp"
+ " and B.USU_CodFil = USU_T135Lig.USU_CodFil"
+ " and B.USU_NumAne = USU_T135Lig.USU_NumAne)),0) Hora_Fim_Atualização,"
+ " NVL((Select Min(E140Nfv.DatGer)"
+ " From E140Nfv,E135Pfa"
+ " Where E140Nfv.CodEmp = E135Pfa.CodEmp"
+ " and E140Nfv.CodFil = E135Pfa.FilNfv"
+ " and E140Nfv.CodSnf = E135Pfa.SnfNfv"
+ " and E140Nfv.NumNfv = E135Pfa.NumNfv"
+ " and E135Pfa.CodEmp = E135Ane.CodEmp"
+ " and E135Pfa.CodFil = E135Ane.CodFil"
+ " and E135Pfa.NumAne = E135Ane.NumAne"
+ " and E135Pfa.NumNfv > 0),"
+ " TO_DATE('31/12/1900','DD/MM/YYYY')) Data_Inicio_Notas,"
+ " NVL((Select Min(E140Nfv.HorGer)"
+ " From E140Nfv,E135Pfa"
+ " Where E140Nfv.CodEmp = E135Pfa.CodEmp"
+ " and E140Nfv.CodFil = E135Pfa.FilNfv"
+ " and E140Nfv.CodSnf = E135Pfa.SnfNfv"
+ " and E140Nfv.NumNfv = E135Pfa.NumNfv"
+ " and E135Pfa.CodEmp = E135Ane.CodEmp"
+ " and E135Pfa.CodFil = E135Ane.CodFil"
+ " and E135Pfa.NumAne = E135Ane.NumAne"
+ " and E140Nfv.DatGer = (Select Min(B.DatGer)"
+ " From E140Nfv B,E135Pfa C"
+ " Where B.CodEmp = C.CodEmp"
+ " and B.CodFil = C.FilNfv"
+ " and B.CodSnf = C.SnfNfv"
+ " and B.NumNfv = C.NumNfv"
+ " and C.CodEmp = E135Ane.CodEmp"
+ " and C.CodFil = E135Ane.CodFil"
+ " and C.NumAne = E135Ane.NumAne"
+ " and C.NumNfv > 0)"
+ " and E135Pfa.NumNfv > 0),0) Hora_Inicio_Notas,"
+ " NVL((Select Max(E140Nfv.DatGer)"
+ " From E140Nfv,E135Pfa"
+ " Where E140Nfv.CodEmp = E135Pfa.CodEmp"
+ " and E140Nfv.CodFil = E135Pfa.FilNfv"
+ " and E140Nfv.CodSnf = E135Pfa.SnfNfv"
+ " and E140Nfv.NumNfv = E135Pfa.NumNfv"
+ " and E135Pfa.CodEmp = E135Ane.CodEmp"
+ " and E135Pfa.CodFil = E135Ane.CodFil"
+ " and E135Pfa.NumAne = E135Ane.NumAne"
+ " and E135Pfa.NumNfv > 0),"
+ " TO_DATE('31/12/1900','DD/MM/YYYY')) Data_Fim_Notas,"
+ " NVL((Select Max(E140Nfv.HorGer)"
+ " From E140Nfv,E135Pfa"
+ " Where E140Nfv.CodEmp = E135Pfa.CodEmp"
+ " and E140Nfv.CodFil = E135Pfa.FilNfv"
+ " and E140Nfv.CodSnf = E135Pfa.SnfNfv"
+ " and E140Nfv.NumNfv = E135Pfa.NumNfv"
+ " and E135Pfa.CodEmp = E135Ane.CodEmp"
+ " and E135Pfa.CodFil = E135Ane.CodFil"
+ " and E135Pfa.NumAne = E135Ane.NumAne"
+ " and E140Nfv.DatGer = (Select Max(B.DatGer)"
+ " From E140Nfv B,E135Pfa C"
+ " Where B.CodEmp = C.CodEmp"
+ " and B.CodFil = C.FilNfv"
+ " and B.CodSnf = C.SnfNfv"
+ " and B.NumNfv = C.NumNfv"
+ " and C.CodEmp = E135Ane.CodEmp"
+ " and C.CodFil = E135Ane.CodFil"
+ " and C.NumAne = E135Ane.NumAne"
+ " and c.NumNfv > 0)"
+ " and E135Pfa.NumNfv > 0),0) Hora_Fim_Notas,"
+ " NVL((Select Min(E301Mcr.DatGer)"
+ " From E301Tcr,E301Mcr,E135Pfa"
+ " Where E301Tcr.CodEmp = E135Pfa.CodEmp"
+ " and E301Tcr.FilNfv = E135Pfa.FilNfv"
+ " and E301Tcr.CodSnf = E135Pfa.SnfNfv"
+ " and E301Tcr.NumNfv = E135Pfa.NumNfv"
+ " and E301Tcr.CodEmp = E301Mcr.CodEmp"
+ " and E301Tcr.CodFil = E301Mcr.CodFil"
+ " and E301Tcr.NumTit = E301Mcr.NumTit"
+ " and E301Tcr.CodTpt = E301Mcr.CodTpt"
+ " and E135Pfa.CodEmp = E135Ane.CodEmp"
+ " and E135Pfa.CodFil = E135Ane.CodFil"
+ " and E135Pfa.NumAne = E135Ane.NumAne"
+ " and E301Mcr.VlrMov = 0"
+ " and E135Pfa.NumNfv > 0),"
+ " TO_DATE('31/12/1900','DD/MM/YYYY')) Data_Inicio_Boletos,"
+ " NVL((Select Min(E301Mcr.HorGer)"
+ " From E301Tcr,E301Mcr,E135Pfa"
+ " Where E301Tcr.CodEmp = E135Pfa.CodEmp"
+ " and E301Tcr.FilNfv = E135Pfa.FilNfv"
+ " and E301Tcr.CodSnf = E135Pfa.SnfNfv"
+ " and E301Tcr.NumNfv = E135Pfa.NumNfv"
+ " and E301Tcr.CodEmp = E301Mcr.CodEmp"
+ " and E301Tcr.CodFil = E301Mcr.CodFil"
+ " and E301Tcr.NumTit = E301Mcr.NumTit"
+ " and E301Tcr.CodTpt = E301Mcr.CodTpt"
+ " and E135Pfa.CodEmp = E135Ane.CodEmp"
+ " and E135Pfa.CodFil = E135Ane.CodFil"
+ " and E135Pfa.NumAne = E135Ane.NumAne"
+ " and E301Mcr.DatGer = (Select Min(E301Mcr.DatGer)"
+ " From E301Tcr B,E301Mcr C,E135Pfa D"
+ " Where B.CodEmp = D.CodEmp"
+ " and B.FilNfv = D.FilNfv"
+ " and B.CodSnf = D.SnfNfv"
+ " and B.NumNfv = D.NumNfv"
+ " and B.CodEmp = C.CodEmp"
+ " and B.CodFil = C.CodFil"
+ " and B.NumTit = C.NumTit"
+ " and B.CodTpt = C.CodTpt"
+ " and D.CodEmp = E135Ane.CodEmp"
+ " and D.CodFil = E135Ane.CodFil"
+ " and D.NumAne = E135Ane.NumAne"
+ " and C.VlrMov = 0"
+ " and D.NumNfv > 0)"
+ " and E301Mcr.VlrMov = 0"
+ " and E135Pfa.NumNfv > 0),0) Hora_Inicio_Boletos,"
+ " NVL((Select Max(E301Mcr.DatGer)"
+ " From E301Tcr,E301Mcr,E135Pfa"
+ " Where E301Tcr.CodEmp = E135Pfa.CodEmp"
+ " and E301Tcr.FilNfv = E135Pfa.FilNfv"
+ " and E301Tcr.CodSnf = E135Pfa.SnfNfv"
+ " and E301Tcr.NumNfv = E135Pfa.NumNfv"
+ " and E301Tcr.CodEmp = E301Mcr.CodEmp"
+ " and E301Tcr.CodFil = E301Mcr.CodFil"
+ " and E301Tcr.NumTit = E301Mcr.NumTit"
+ " and E301Tcr.CodTpt = E301Mcr.CodTpt"
+ " and E135Pfa.CodEmp = E135Ane.CodEmp"
+ " and E135Pfa.CodFil = E135Ane.CodFil"
+ " and E135Pfa.NumAne = E135Ane.NumAne"
+ " and E135Pfa.NumNfv > 0"
+ " and E301Mcr.VlrMov = 0),"
+ " TO_DATE('31/12/1900','DD/MM/YYYY')) Data_Fim_Boletos,"
+ " NVL((Select Max(E301Mcr.HorGer)"
+ " From E301Tcr,E301Mcr,E135Pfa"
+ " Where E301Tcr.CodEmp = E135Pfa.CodEmp"
+ " and E301Tcr.FilNfv = E135Pfa.FilNfv"
+ " and E301Tcr.CodSnf = E135Pfa.SnfNfv"
+ " and E301Tcr.NumNfv = E135Pfa.NumNfv"
+ " and E301Tcr.CodEmp = E301Mcr.CodEmp"
+ " and E301Tcr.CodFil = E301Mcr.CodFil"
+ " and E301Tcr.NumTit = E301Mcr.NumTit"
+ " and E301Tcr.CodTpt = E301Mcr.CodTpt"
+ " and E135Pfa.CodEmp = E135Ane.CodEmp"
+ " and E135Pfa.CodFil = E135Ane.CodFil"
+ " and E135Pfa.NumAne = E135Ane.NumAne"
+ " and E301Mcr.DatGer = (Select Max(E301Mcr.DatGer)"
+ " From E301Tcr B,E301Mcr C,E135Pfa D"
+ " Where B.CodEmp = D.CodEmp"
+ " and B.FilNfv = D.FilNfv"
+ " and B.CodSnf = D.SnfNfv"
+ " and B.NumNfv = D.NumNfv"
+ " and B.CodEmp = C.CodEmp"
+ " and B.CodFil = C.CodFil"
+ " and B.NumTit = C.NumTit"
+ " and B.CodTpt = C.CodTpt"
+ " and D.CodEmp = E135Ane.CodEmp"
+ " and D.CodFil = E135Ane.CodFil"
+ " and D.NumAne = E135Ane.NumAne"
+ " and C.VlrMov = 0"
+ " and D.NumNfv > 0)"
+ " and E301Mcr.VlrMov = 0"
+ " and E135Pfa.NumNfv > 0),0) Hora_Fim_Boletos"
+ "From E135Ane"
+ "Where ((E135Ane.SitCar = 'A') or"
+ " (E135Ane.SitCar = 'F' and exists (Select 1"
+ " From E135Pfa"
+ " Where E135Pfa.CodEmp = E135Ane.CodEmp"
+ " and E135Pfa.CodFil = E135Ane.CodFil"
+ " and E135Pfa.NumAne = E135Ane.NumAne"
+ " and E135Pfa.SitPfa in (1, 2, 3))) or"
+ " (exists (Select 1"
+ " From E140Nfv,E135Pfa"
+ " Where E140Nfv.CodEmp = E135Pfa.CodEmp"
+ " and E140Nfv.CodFil = E135Pfa.FilNfv"
+ " and E140Nfv.CodSnf = E135Pfa.SnfNfv"
+ " and E140Nfv.NumNfv = E135Pfa.NumNfv"
+ " and E135Pfa.CodEmp = E135Ane.CodEmp"
+ " and E135Pfa.CodFil = E135Ane.CodFil"
+ " and E135Pfa.NumAne = E135Ane.NumAne"
+ " and E135Pfa.NumNfv > 0"
+ " and E140Nfv.DatGer = TO_DATE(TO_CHAR(SYSDATE,'DD/MM/YYYY'),'DD/MM/YYYY'))))"
+ "Order By E135Ane.DatGer,E135Ane.HorGer";
Agradeço a atenção de todos, obrigado.
Att,
Graziani Garcia