The following lines contain the word 'select', 'insert', 'update' or 'delete':
l_log_msg := 'Step 5: Update the posted flag';
UPDATE AP_INVOICE_DISTRIBUTIONS
SET POSTED_FLAG = 'N'
WHERE Accounting_Event_ID = l_event_list(num);
UPDATE ap_prepay_history_all
SET POSTED_FLAG = 'N'
WHERE Accounting_Event_ID = l_event_list(num);
l_event_list.DELETE;
l_t_array_event_info.DELETE;
l_log_msg := 'Step 5: Update the posted flag';
UPDATE AP_invoice_payments_all
SET POSTED_FLAG = CASE WHEN l_accounting_mode <> 'D'
AND p_retcode <> 0
AND l_event_status_list(num) <> 'P'
THEN 'N'
WHEN l_accounting_mode <> 'D'
AND p_retcode = 0
AND l_event_status_list(num) = 'U'
AND EXISTS(SELECT 1
FROM ap_system_parameters asp, ap_payment_history_all aph
WHERE asp.when_to_account_pmt = 'CLEARING ONLY'
--AND asp.org_id = l_org_id
AND asp.org_id = aph.org_id
AND aph.accounting_event_id = l_event_list(num)
AND aph.transaction_type in ('PAYMENT CREATED', 'PAYMENT MATURITY')
)
THEN 'Y'
ELSE POSTED_FLAG
END
WHERE Accounting_Event_ID = l_event_list(num);
UPDATE AP_payment_history_all APH
SET APH.POSTED_FLAG = CASE WHEN l_accounting_mode <> 'D'
AND p_retcode <> 0
AND l_event_status_list(num) <> 'P'
THEN 'N'
WHEN l_accounting_mode <> 'D'
AND p_retcode = 0
AND l_event_status_list(num) = 'U'
AND EXISTS(SELECT 1
FROM ap_system_parameters asp
WHERE asp.when_to_account_pmt = 'CLEARING ONLY'
--AND asp.org_id = l_org_id
AND asp.org_id = aph.org_id
AND aph.accounting_event_id = l_event_list(num)
AND aph.transaction_type in ('PAYMENT CREATED', 'PAYMENT MATURITY')
)
THEN 'Y'
WHEN l_accounting_mode <> 'D' -- Bug 7374984
AND p_retcode = 0
AND l_event_status_list(num) = 'N'
THEN 'Y'
ELSE POSTED_FLAG
END
WHERE APH.Accounting_Event_ID = l_event_list(num);
l_event_list.DELETE;
l_event_status_list.DELETE;
l_t_array_event_info.DELETE;
select invoice_num
into l_invoice_num
from ap_invoices
where invoice_id = p_invoice_id;
select check_number
into l_check_number
from ap_checks
where check_id = p_check_id;
SELECT
AI.org_id,
AI.legal_entity_id,
AI.set_of_books_id
INTO
p_org_id,
p_legal_entity_id,
p_ledger_id
FROM
ap_invoices AI
WHERE
AI.invoice_id = p_invoice_id;
SELECT AC.org_id,
AC.legal_entity_id
INTO p_org_id,
p_legal_entity_id
FROM ap_checks AC
WHERE AC.check_id = p_check_id;
SELECT AIP.set_of_books_id
INTO p_ledger_id
FROM ap_invoice_payments AIP
WHERE AIP.check_id = p_check_id
AND ROWNUM = 1;