Trying to get this query to run. The colons are parameterization next to what would be the input.
SELECT DISTINCT pa.kas_pa, pa.auth_num FROM t_pa_path pa, t_pa_a_item ai
WHERE (pa.kas_receipt = :kas_receipt OR
pa.ID_receipt_KEYED = :id_receipt_keyed OR
pa.kas_receipt IN (SELECT kas_rcp_purged FROM t_receipt_link_xref WHERE kas_receipt = :kas_receipt AND cde_status = 'Z') )
AND pa.auth_num <> :auth_num
AND pa.kas_pa = ai.kas_pa
AND pa.kas_payer_one = :kas_payer_one
AND pa.ind_special = :ind_special
AND pa.ind_emerg = :ind_emerg
AND pa.the_status IN ('A','B','C','D','E')
AND pa.kas_prov_loc IN (SELECT kas_prov_loc FROM t_pr_identifier WHERE RTRIM(id_other_cust) = :id_prov_keyed)
AND :cde_keyed IN (ai.cde_keyed, ai.cde_2_keyed, ai.cde_3_keyed, ai.cde_4_keyed)
AND ai.cde_keyed IN (' ',:cde_keyed)
AND ai.cde_2_keyed IN (' ',:cde_keyed)
AND ai.cde_3_keyed IN (' ',:cde_keyed)
AND ai.cde_4_keyed IN (' ',:cde_keyed)
AND ai.the_STATUS IN ('A','C','E','G','W')
AND ai.kas_proceding = :kas_proceding
OR EXISTS (SELECT 1 FROM t_pa_a_item ai, t_dup_svc ds JOIN t_prog p ON ds.cde_proceding_2=rtrim(p.cde_proc)
WHERE ds.cde_tax_1 = :cde_tax_1
AND ds.cde_proceding_1 = :cde_proceding_1
AND ds.cde_1 = :cde_1
AND ds.cde_tax_2 = ai.cde_tax
AND p.kas_proceding = ai.kas_proceding
AND ds.cde_2 = ai.cde_keyed)
OR EXISTS (SELECT 1 FROM t_pa_a_item ai, t_dup_svc ds JOIN t_prog p ON ds.cde_proceding_1=rtrim(p.cde_proc)
WHERE ds.cde_tax_2 = :cde_tax_1
AND ds.cde_proceding_2 = :cde_proceding_1
AND ds.cde_2 = :cde_1
AND ds.cde_tax_1 = ai.cde_tax
AND p.kas_proceding = ai.kas_proceding
AND ds.cde_1 = ai.cde_keyed)
AND ( ai.dte_pa_req_eff = :dte_pa_req_eff OR
((:dte_pa_req_eff BETWEEN ai.DTE_PA_REQ_EFF AND ai.DTE_PA_REQ_END ) OR
( :dte_pa_req_end BETWEEN ai.DTE_PA_REQ_EFF AND ai.DTE_PA_REQ_END ) OR
( :dte_pa_req_eff < ai.DTE_PA_REQ_EFF AND :dte_pa_req_end > ai.DTE_PA_REQ_END ) ));
When I run the entire query, it just hangs.
When I run the query from the beginning to right before the first OR EXISTS, the query works (no error, no hanging).
If I take out the first OR EXISTS, and leave the 2nd one in there, that entire query works (no hanging, no errors).
So the issue seems to be with both OR EXISTS together, or perhaps something with the first OR EXISTS.
Any ideas or suggestions?
Thanks.