Question:
Hello, I've been working with oracle for a short time, and I'm having this problem in the query, it returns the error: ORA-00907: right parenthesis not found, below is the same:
("""select
ordem.id,ordem.data_prog,ordem.rms, ordem.pkpk, medida.ganho,ponto.descricao as ponto, unidade.id as id_unid, unidade.id_segmento as segmento,equipamento.id as id_equipamento,codigo.id, codigo.descricao
from intranet.vb_item_ordem_servico ordem
join intranet.vb_ponto_medida medida on medida.id = ordem.id_ponto_medida
join intranet.vb_ponto ponto on ponto.id = medida.id_vb_ponto
join intranet.gm_arvore arvore on arvore.id = ponto.id_arvore
join intranet.cd_unidade unidade on unidade.id = arvore.id_unidade
join intranet.gm_equipamento_arvore equipamento on equipamento.id = arvore.id
join intranet.ce_tipo_equipamento codigo on codigo.id = equipamento.id_tipo_equipamento
where (ordem.data_prog between date_sub(to_date('{}', 'DD/MM/YYYY'), INTERVAL {} MONTH) and to_date('{}', 'DD/MM/YYYY')) AND codigo.id='{}' """).format(data_prog, intervalo,data_prog, id)
Could someone tell me where I'm going wrong.
Thank you in advance
Answer:
I don't know Oracle, but your where
has a right parenthesis ')' that doesn't "match" with anyone, put it in a qt-console terminal (I think it works on ipython too) and browse the code line and parentheses of opening and closing are highlighted, I did this with its where
and Rapahel's reply and found (in both) a "single" closing parenthesis.
where (ordem.data_prog between date_sub(to_date('{}', 'DD/MM/YYYY'), INTERVAL {} MONTH) and to_date('{}', 'DD/MM/YYYY')) AND codigo.id='{}' """).format(data_prog, intervalo,data_prog, id)
).format(data_prog, intervalo,data_prog, id)
^
Esse parenteses está "solteiro"