The following lines contain the word 'select', 'insert', 'update' or 'delete':
SELECT pd.line_location_id,
pd.po_line_id,
decode(pd.po_release_id, null, pd.po_header_id, pd.po_release_id),
decode(ph.type_lookup_code, 'STANDARD', 'PO', 'RELEASE'),
decode(pd.po_release_id, NULL, ph.type_lookup_code,
pr.release_type),
MAX(aid.accounting_date)
INTO l_line_location_id,
l_po_line_id,
l_po_header_id,
l_po_doc_type,
l_po_sub_type,
l_inv_accounting_date
FROM po_distributions pd,
po_headers ph,
po_releases pr,
ap_invoice_distributions aid,
po_line_locations pll -- Bug 3706938
WHERE aid.invoice_id = P_invoice_id
AND aid.po_distribution_id = pd.po_distribution_id
AND ph.po_header_id = pd.po_header_id
AND ph.po_header_id = pll.po_header_id -- Bug 3706938
AND pll.line_location_id = pd.line_location_id
AND pd.po_release_id = pr.po_release_id(+)
-- AND aid.final_match_flag = 'D' -- Bug 3706938
AND decode(PLL.final_match_flag, 'Y', 'D', NVL(AID.final_match_flag, 'N')) = 'D' -- Bug 3706938
GROUP BY pd.line_location_id,
pd.po_line_id,
decode(pd.po_release_id, null, pd.po_header_id, pd.po_release_id),
decode(ph.type_lookup_code, 'STANDARD', 'PO', 'RELEASE'),
decode(pd.po_release_id, NULL, ph.type_lookup_code,
pr.release_type);