The following lines contain the word 'select', 'insert', 'update' or 'delete':
l_cp_orig_select VARCHAR2(120);
DELETE FROM AR_IL_CASH_RECEIPTS_GT;
SELECT user_name
INTO l_user
FROM fnd_user
WHERE user_id=fnd_global.user_id;
SELECT concurrent_program_id
INTO ln_conc_program_id
FROM fnd_concurrent_programs
WHERE concurrent_program_name=p_program_short_name;
UPDATE fnd_concurrent_requests
SET save_output_flag='N'
WHERE request_id = ln_request_id
AND concurrent_program_id = ln_conc_program_id;
l_cp_orig_select := ''''||l_orig_string||''' ORIG_COPY';
l_cp_orig_select := ''''||l_copy_string||''' ORIG_COPY';
l_stmt := 'INSERT INTO AR_IL_CASH_RECEIPTS_GT(
CASH_RECEIPT_ID
,RECEIPT_NUMBER
,RECEIPT_DATE
,RECEIPT_STATUS
,DOCUMENT_NUMBER
,RECEIPT_AMOUNT
,CURRENCY
,CREDIT_CARD_NO
,CREDIT_CARD_TYPE
,MATURITY_DATE
,METHOD_NAME
,BANK_ACCOUNT
,BANK_NAME
,BANK_BRANCH_NAME
,CUSTOMER_NAME
,CUSTOMER_NUMBER
,TAX_REGISTRATION_NUMBER
,CUST_ACCOUNT_ID
,CUST_ACCT_SITE_ID
,ADDRESS_LINE1
,ADDRESS_LINE2
,CITY
,POSTAL_CODE
,COPY_OR_ORIGINAL
,USER_NAME)
SELECT /* Receipt Information */
acr.cash_receipt_id CASH_RECEIPT_ID
,acr.receipt_number RECEIPT_NUMBER
,acr.receipt_date RECEIPT_DATE
,acr.status RECEIPT_STATUS
,acr.doc_sequence_value DOCUMENT_NUMBER
,acr.amount RECEIPT_AMOUNT
,acr.currency_code CURRENCY
,acr.attribute13 CREDIT_CARD_NO
,acr.attribute14 CREDIT_CARD_TYPE
,aps.due_date MATURITY_DATE
,arm.name METHOD_NAME
/* Bank Information */
,iebav.bank_account_number BANK_ACCOUNT
,NVL(cbbv1.bank_name,cbbv2.bank_name) BANK_NAME
,NVL(cbbv1.bank_branch_name,cbbv2.bank_branch_name) BANK_BRANCH_NAME
/* Customer Information */
,hp.party_name CUSTOMER_NAME
,hca.account_number CUSTOMER_NUMBER
,(select registration_number
from xle_firstparty_information_v
where legal_entity_id = acr.legal_entity_id) TAX_REGISTRATION_NUMBER
/* The next two columns would be used to automatically
join to Q_INVOICES */
,hca.cust_account_id CUST_ACCOUNT_ID
,hcas.cust_acct_site_id CUST_ACCT_SITE_ID
/* Customer Address */
,hl.address1 ADDRESS_LINE1
,hl.address2 ADDRESS_LINE2
,hl.city CITY
,hl.postal_code POSTAL_CODE,'||l_cp_orig_select||l_user||'
FROM ar_cash_receipts acr,
ar_receipt_methods arm,
ar_payment_schedules aps,
iby_ext_bank_accounts_v iebav,
ce_bank_branches_v cbbv1,
ce_bank_branches_v cbbv2,
hz_parties hp,
hz_party_sites hps,
hz_cust_accounts hca,
hz_cust_acct_sites hcas,
hz_cust_site_uses hcsu,
hz_locations hl
WHERE aps.cash_receipt_id = acr.cash_receipt_id
AND acr.status IN (''APP'',''REV'',''NSF'',''STOP'')
AND acr.confirmed_flag=''Y''
AND arm.receipt_method_id = acr.receipt_method_id
AND iebav.ext_bank_account_id (+) = acr.customer_bank_account_id
AND iebav.branch_party_id = cbbv1.branch_party_id(+)
AND acr.customer_bank_branch_id = cbbv2.branch_party_id (+)
AND acr.pay_from_customer = hca.cust_account_id
AND acr.customer_site_use_id = hcsu.site_use_id (+)
AND hcsu.cust_acct_site_id = hcas.cust_acct_site_id
AND hp.party_id = hca.party_id
AND hca.cust_account_id = hcas.cust_account_id
AND hcas.party_site_id = hps.party_site_id
AND hps.location_id = hl.location_id'
||l_date_filter||l_receipt_filter||l_doc_filter||l_cust_filter||l_cp_orig_filter;
PROCEDURE update_ar_cash_receipts
IS
BEGIN
IF p_copy_or_original='Original' THEN
UPDATE ar_cash_receipts_all
SET global_attribute20 = 'Printed'
WHERE cash_receipt_id in (SELECT cash_receipt_id
FROM AR_IL_CASH_RECEIPTS_GT);
update_ar_cash_receipts;